This forum is reserved for everything you want to talk about. It could be about programming, opinions, open source programs, development in general, or just cool stuff to share!
1 post • Page 1 of 1
Let's say that I have a base class, with many classes derived through inheritance, and I want to store all instances of the base/derived classes in a container storing, say, smart pointers of the type std::unique_ptr<base>, which stores a pointer to the base class. It seems that with the addition of the emplace() methods to the STL, it would be feasible, perhaps even more efficient than otherwise, to write a custom allocator whose construct() method acts as a factory for producing a pointer of the correct base/derived class and then setting the std::unique_ptr<base> smart pointer that is being constructed inside the container to point to the base/derived class.
Who is online
Users browsing this forum: No registered users and 2 guests