Normally I call reserve
on a std::vector
immediately after constructing it. Wouldn't this typically cause the std::vector
's existing heap allocation to be destroyed and replaced with a new one? Is there a way to reserve the memory at construction time rather than allocate heap space and then immediately destroy it? Or is there an implemenatation trick within the std::vector
to ensure this is not an issue?
The available constructors only seem to be able to be useful for filling the std::vector
with values, rather than reserving space explicitly.