1
0
mirror of https://gitlab.com/hashborgir/d2tweaks-rnd2k.git synced 2025-04-30 16:15:33 +00:00
2024-04-16 21:45:38 -06:00

21 lines
376 B
C++

#pragma once
template<typename T>
class singleton {
public:
static T& instance();
singleton(const singleton&) = delete;
singleton& operator= (singleton) = delete;
protected:
struct token {};
singleton() = default;
};
#include <memory>
template<typename T>
T& singleton<T>::instance() {
static const std::unique_ptr<T> instance{ new T{token{}} };
return *instance;
}