mirror of
https://github.com/barkeser2002/flower.git
synced 2026-09-25 14:16:14 +03:00
22 lines
374 B
C++
22 lines
374 B
C++
#pragma once
|
|
|
|
namespace Flower
|
|
{
|
|
template <typename T>
|
|
class Singleton
|
|
{
|
|
private:
|
|
Singleton() { }
|
|
Singleton(const Singleton& rhs) { }
|
|
Singleton& operator= (const Singleton& rhs) { }
|
|
|
|
public:
|
|
// No dll export safe, but current enough.
|
|
static T* get()
|
|
{
|
|
// After c++ 11 this process is thread safe.
|
|
static T singleton{ };
|
|
return &singleton;
|
|
}
|
|
};
|
|
} |