Private constructor and make_shared

后端 未结 3 1662
生来不讨喜
生来不讨喜 2021-01-06 20:34

I have a singleton class with a private constructor. In the static factory method I do the following:

shared_ptr MyClass::GetInstance()
{
             


        
3条回答
  •  盖世英雄少女心
    2021-01-06 21:16

    You should use Meyers singleton instead. You should ensure that your compiler supports C++11 magic static before.

提交回复
热议问题