This commit is contained in:
Attila Body 2025-05-27 19:51:33 +02:00
parent 033122ffb3
commit 2a52eee7ad
Signed by: abody
GPG key ID: BD0C6214E68FB5CF
19 changed files with 1882 additions and 57139 deletions

26
Inc/singleton.h Normal file
View file

@ -0,0 +1,26 @@
#ifndef SINGLETON_H_
#define SINGLETON_H_
#include <utility>
template<typename T> class Singleton {
public:
static T &Instance() { return *m_instance; }
template<typename ... Args>
static T &Init(Args &&... args)
{
static T instance{ std::forward<Args>(args)... };
m_instance = &instance;
return instance;
}
protected:
Singleton() = default;
Singleton(const Singleton &) = delete;
Singleton &operator=(const Singleton &) = delete;
static T *m_instance;
};
template<typename T> T* Singleton<T>::m_instance = nullptr;
#endif /* SINGLETON_H_ */