how to make friend function of std::make_shared().
I tried:
class MyClass{
public:
friend std::shared_ptr<MyClass> std::make_shared<MyClass>();
//or
//friend std::shared_ptr<MyClass> std::make_shared();
protected:
MyClass();
};
but it does not work (i’am using Visual Studio 2010 SP1)
How about adding a static method to your class:
Here’s a little hackaround:
Nobody can use the public constructor other than the class itself. It’s essentially a non-interface part of the public interface. Ask the Java people if such a thing has a name 🙂