C++11 Smart Pointer Make Functions for Variable Sized Objects

Viewed 356

Consider I have a class with no public constructor, but a static factory or builder method, and the size of the created object depends on the arguments passed to the factory (or builder).

Is there a way to create a shared (or unique) pointer to such an object using std::make_shared (or std::make_unique)?

For any suggested polymorphism, I prefer templates over virtual methods.

3 Answers
Related