Signed-off-by: myperworld <myperworld@126.com>

This commit is contained in:
myperworld committed 2025-10-06 12:34:26 +08:00
1 parent 0986832fd1
commit aacd052c06
3403 files changed
+597376 -12

No files matched your search

@@ -0,0 +1,26 @@
#pragma once
#include "fl/namespace.h"
namespace fl {
// A templated singleton class, parameterized by the type of the singleton and
// an optional integer.
template <typename T, int N = 0> class Singleton {
public:
static T &instance() {
// We love function level singletons!! They don't get construction until first call.
// And they seem to have locks on them in most compilers. So yay.
static T instance;
return instance;
}
static T *instanceRef() { return &instance(); }
Singleton(const Singleton &) = delete;
Singleton &operator=(const Singleton &) = delete;
private:
Singleton() = default;
~Singleton() = default;
};
} // namespace fl