Consider following code:
#include
// =============================
class Shape{
public:
virtual ~Shape(){};
virtual void process
I think the most idiomatic modern C++ method is the one you mention in passing but ignore. Return a std::unique_ptr.
It is safe, clearly expresses ownership, supports polymorphism and doesn't need much code.
class ShapeFactory {
public:
std::unique_ptr create(){
return std::make_unique();
}
};
But I wouldn't want to claim it was the "best" method.
Your PimplShape in option 3 is actually very similar to a unique_ptr just less generic or tested.