emsApplication/applications/emsConfigurer/singleton.h

24 lines
520 B
C++

#ifndef SINGLETON_H
#define SINGLETON_H
#pragma execution_character_set("utf-8")
template<typename T>
class Singleton
{
public:
static T* getInstance() noexcept(std::is_nothrow_constructible<T>::value)
{
static T instance{token()};
return &instance;
}
virtual ~Singleton() =default;
Singleton(const Singleton&)=delete;
Singleton& operator =(const Singleton&)=delete;
protected:
struct token {}; // helper class
Singleton() noexcept=default;
};
#endif // SINGLETON_H