Is there a standard container that has the same common API as it does vector<T>, but which fills new locations with a direct default construction?
Background:
I have a type that forbids copying, but has a default constructor, and I really want to do this:
vector<NoCopy> bag(some_size);
return;
However, this does not work, because it vector<T>(int)is implemented in terms of constructing an object by default, and then copies it to each new location.
Edit: Not C ++ 0xB (aka C ++ 11)
source
share