cf::SimpleSingleton¶
Simple thread-safe singleton using Meyer's singleton pattern. More...
#include <simple_singleton.hpp>
Public Functions¶
| Name | |
|---|---|
| SingleTargetClass & | instance() Returns the singleton instance. |
Detailed Description¶
Simple thread-safe singleton using Meyer's singleton pattern.
Template Parameters:
- SingleTargetClass Type of the singleton instance.
Note: Thread-safe. C++11 guarantees thread-safe initialization of function-local static variables.
Warning: None
Provides a minimal singleton implementation that leverages C++11 guarantees for thread-safe static local variable initialization. The instance is created on first access and destroyed on application exit.
class MyClass {
public:
void doSomething() {}
};
using MySingleton = SimpleSingleton<MyClass>;
MySingleton::instance().doSomething();
Public Functions Documentation¶
function instance¶
Returns the singleton instance.
Exceptions:
- None
Return: Reference to the singleton instance.
Since: N/A
Note: Thread-safe initialization guaranteed by C++11 standard.
Warning: None
Creates the instance on first call, subsequent calls return the same instance.
Updated on 2026-03-09 at 10:14:00 +0000