1 2 3 4 5 6 7 8 9 10 11 | template < typename Type > class singleton { public: static Type& get_instance() { static Type unique_instance; return unique_instance; } }; | cs |
이렇게 쓰면 될 거에요 아마.
c++11 스펙 이후로는 멀티 스레드 환경에서도 생성에 lock 걸 필요도 없는거로 앎
1 2 3 4 5 6 7 8 9 10 11 | template < typename Type > class singleton { public: static Type& get_instance() { static Type unique_instance; return unique_instance; } }; | cs |
이렇게 쓰면 될 거에요 아마.
c++11 스펙 이후로는 멀티 스레드 환경에서도 생성에 lock 걸 필요도 없는거로 앎
class sound_manager : public singleton<sound_manager>
요런식으로
와 간단하네;