Managing a singleton destructor

后端 未结 6 1761
眼角桃花
眼角桃花 2020-12-18 04:08

The following small example implements a singleton pattern that I\'ve seen many times:

#include 

class SingletonTest {
private:
  Singleton         


        
6条回答
  •  青春惊慌失措
    2020-12-18 04:43

    if you declare the class which does the actual delete op as a friend (let it be shared_ptr or some kind of default deleter) a friend, your destructor can be private. Although i dont see any necessarity for making it private.

提交回复
热议问题