Kinda works

This commit is contained in:
Attila Body 2021-10-31 00:33:00 +02:00
parent f3d345e2e3
commit 662a7a9b12
40 changed files with 2851 additions and 26 deletions

View file

@ -0,0 +1,39 @@
/*
* singleton.h
*
* Created on: Sep 11, 2019
* Author: compi
*/
#ifndef SINGLETON_H_
#define SINGLETON_H_
#include <utility>
namespace f4ll_cpp {
template<typename T> class Strangeton {
public:
static T &Instance() {
return *m_instance;
}
template<typename ... Args> static T &Init(Args &&... args) {
static T instance{ std::forward<Args>(args)... };
if(!m_instance)
m_instance = &instance;
return instance;
}
protected:
Strangeton() = default;
Strangeton(const Strangeton &) = delete;
Strangeton &operator=(const Strangeton &) = delete;
virtual ~Strangeton() = default;
static T *m_instance;
};
template<typename T> T* Strangeton<T>::m_instance = nullptr;
} // f4ll_cpp
#endif /* SINGLETON_H_ */