添加creeper-qt最新依赖
This commit is contained in:
23
creeper-qt/utility/wrapper/singleton.hh
Normal file
23
creeper-qt/utility/wrapper/singleton.hh
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
namespace creeper::util {
|
||||
|
||||
template <typename T> class Singleton {
|
||||
public:
|
||||
static T& instance();
|
||||
|
||||
Singleton(const Singleton&) = delete;
|
||||
Singleton& operator=(const Singleton&) = delete;
|
||||
|
||||
protected:
|
||||
struct token { };
|
||||
Singleton() = default;
|
||||
};
|
||||
|
||||
template <typename T> inline T& Singleton<T>::instance() {
|
||||
static const std::unique_ptr<T> instance { new T { token {} } };
|
||||
return *instance;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user