Banuba SDK
Loading...
Searching...
No Matches
singleton.hpp
1#pragma once
2
3#include <bnb/utils/assert.hpp>
4
5namespace bnb
6{
7 /**
8 * @addtogroup Utils
9 * @{
10 */
11
12 /// \brief Base class for all scoped singletons.
13 ///
14 /// This is a Meyers Singleton implementation.
15 ///
16 template<typename T>
18 {
19 public:
20 singleton(const singleton<T>& other) = delete;
21 singleton<T>& operator=(const singleton<T>& other) = delete;
22
23 static T& instance()
24 {
25 static T instance;
26 return instance;
27 }
28
29 protected:
30 singleton() = default;
31 ~singleton() = default;
32 };
33
34 /** @} */ // endgroup utils
35} // namespace bnb
Base class for all scoped singletons.
Definition singleton.hpp:18