Template Class Singleton

Inheritance Relationships

Derived Types

Class Documentation

template<class Type>
class Singleton

CE::State::Singleton (Compile Time Safe) For simple singleton creation.

You can keep inheriting these all you want, it will always be the same instance they point to. Uses static_assert verifying constructibility - requires public constructor(s) initialize(args…) accepts exactly one successful explicit initialization; repeated calls reject. Configure argument-bearing instances on their owner thread before starting producers. get(args…) remains a compatibility accessor: the first successful construction wins and later arguments are ignored. get() constructs a default-constructible Type, otherwise it only retrieves a published instance. A failed constructor publishes nothing and permits retry. Nonconstructing reads never wait for construction. Construction/publication is synchronized; Type’s later operations require its own thread-safety contract. Returned pointers/references borrow process-lifetime storage, not ownership. Quiesce all callers before static destruction; neither get_existing() nor a successful read pins an instance against teardown.

Subclassed by CE::Memory::Manager< 2.0, 4096 >, CE::Memory::Manager< 1.0, 0 >, CE::Memory::Manager< 4.0, 4096 >, CE::Memory::Manager< 1.29, sizeof(T) *64 >

Public Static Functions

static inline Type *get_existing() noexcept

Declaration: [[nodiscard]]

template<typename ...Args>
static inline Type &initialize(Args&&... args)
template<typename ...Args>
static inline Type &get(Args&&... args)

Retrieve a published instance, constructing it once when these arguments permit it.

Constructors must not recursively initialize/get the same singleton. Later argument values do not replace an existing instance. Construction failures publish nothing; unavailable nonconstructing reads throw.

Parameters:

args – Forwarded constructor arguments on the first successful call.

Returns:

Borrowed process-lifetime instance; its operations have their own thread contract.