Kinda works
This commit is contained in:
parent
f3d345e2e3
commit
662a7a9b12
40 changed files with 2851 additions and 26 deletions
34
components/f4ll_cpp/singleton.h
Normal file
34
components/f4ll_cpp/singleton.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* singleton.h
|
||||
*
|
||||
* Created on: Sep 11, 2019
|
||||
* Author: compi
|
||||
*/
|
||||
|
||||
#ifndef SINGLETON_H_
|
||||
#define SINGLETON_H_
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace f4ll_cpp {
|
||||
|
||||
template<typename T> class Singleton {
|
||||
public:
|
||||
static T &Instance() {
|
||||
static T instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
protected:
|
||||
Singleton() = default;
|
||||
Singleton(const Singleton &) = delete;
|
||||
Singleton &operator=(const Singleton &) = delete;
|
||||
virtual ~Singleton() = default;
|
||||
static T *m_instance;
|
||||
};
|
||||
|
||||
template<typename T> T* Singleton<T>::m_instance = nullptr;
|
||||
|
||||
} // f4ll_cpp
|
||||
|
||||
#endif /* SINGLETON_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue