#include <Singleton.h>
|
| | Singleton (const Singleton &)=delete |
| | Copy constructor is deleted to prevent duplicating the singleton instance.
|
| |
| Singleton & | operator= (const Singleton &)=delete |
| | Assignment operator is deleted to prevent duplicating the singleton instance.
|
| |
|
| static Derived & | getInstance () |
| | Gets the singleton instance of the derived class.
|
| |
|
| | Singleton ()=default |
| | Default constructor is protected to prevent instantiation outside of derived classes.
|
| |
| | ~Singleton ()=default |
| | Default destructor is protected to prevent deletion through base class pointer.
|
| |
◆ Singleton() [1/2]
template<typename Derived>
Copy constructor is deleted to prevent duplicating the singleton instance.
◆ Singleton() [2/2]
template<typename Derived>
Default constructor is protected to prevent instantiation outside of derived classes.
Derived classes should declare Singleton as a friend class to allow instantiation while keeping their constructors protected or private.
◆ ~Singleton()
template<typename Derived>
Default destructor is protected to prevent deletion through base class pointer.
◆ getInstance()
template<typename Derived>
Gets the singleton instance of the derived class.
This method creates the instance on first call (lazy initialization) and returns a reference to it on all subsequent calls. The instance is created as a static variable, ensuring thread-safe initialization in C++11 and above.
- Return values
-
| Derived& | Reference to the singleton instance of the derived class |
◆ operator=()
template<typename Derived>
Assignment operator is deleted to prevent duplicating the singleton instance.
The documentation for this class was generated from the following file: