First, instead of your reserve
/ loop thingy, you can simply use resize
to achieve what your imaginary constructor will do:
const int n = 10; std::vector<Foo, Alloc> foos(allocator); foo.resize(n);
Another option is to use three versions of the size_type n
constructor argument:
const int n = 10; std::vector<Foo, Alloc> foos(n, Foo(), allocator);
Although this actually copies the designs into elements that may or may not be acceptable.
About the logic? No idea. Probably did not pay attention.
source share