I don't understand what this function is really doing. I can see pv is a void pointer with the address that p has (I think), and then the second line constructs an object T at address pv, using the copy constructor?
I can see pv is a void pointer with the address that p has (I think), and then the second line constructs an object T at address pv, using the copy constructor?
I believe everything is correct there, but manual memory management can be tricky. I would say you may get rid of the default constructor requirement for certain uses (as oopposed to getting rid of the requirement altogether), such as the constructor illustrated here. However, if you want to use std::vector::resize functionality, obviously that cannot be done without a default constructor. Whether or not the requirement to use an element's default constructor is in place for this Vector constructor, the copy constructor is also required -- so you're not exchanging one requirement for another.
He meant he couldn't find any useful information in placement new, not that he couldn't find an issue for it. The reason he is looking up placement new was because I told him he needed to use it for his vector class (and he does).
Well, I think I need to use in my allocation class. I'd prefer to keep memory allocation separate from the vector class, and have it handled by an allocation class. This way when I get on to making the rest of the common data structures I can just reuse the same allocation interface, I think. Not sure how I'll work that out for non-contiguous structures.