Private constructor and make_shared
I have a singleton class with a private constructor. In the static factory method I do the following: shared_ptr<MyClass> MyClass::GetInstance() { static once_flag onceFlag; call_once(onceFlag, []() { if (_instance == nullptr) _instance.reset(new MyClass()); }); return _instance; } If I use _instance = make_shared<MyClass>(); the code does not compile. My question is: why new can invoke a private constructor but make_shared not? As mentioned, std::make_shared or its component parts don't have access to private members. the call_once and once_flag are un-necessary. They are implicit in c++11