CSingletonBase.h 449 B

1234567891011121314151617181920212223
  1. #pragma once
  2. #include <type_traits>
  3. template <typename T>
  4. class CSingletonBase
  5. {
  6. public:
  7. static T &get_instance() noexcept(std::is_nothrow_constructible<T>::value)
  8. {
  9. static T instance;
  10. return instance;
  11. }
  12. virtual ~CSingletonBase() noexcept
  13. {
  14. }
  15. CSingletonBase(const CSingletonBase &) = delete;
  16. CSingletonBase &operator=(const CSingletonBase &) = delete;
  17. protected:
  18. CSingletonBase()
  19. {
  20. }
  21. };