1#ifndef ORIGINAL_SINGLETON_H
2#define ORIGINAL_SINGLETON_H
24 template<
typename TYPE>
75 template<
typename... Args>
76 static void init(Args&&... args);
107 template<
typename... Args>
108 static void reset(Args&&... args);
112template<
typename TYPE>
115template <
typename TYPE>
117 return instance_ !=
nullptr;
120template <
typename TYPE>
121template <
typename ... Args>
123 if (instance_ ==
nullptr) {
124 instance_ = std::move(makeOwnerPtr<TYPE>(std::forward<Args>(args)...));
126 throw valueError(
"Instance already exists, do you mean reset(args...)?");
130template <
typename TYPE>
132 if (instance_ ==
nullptr) {
138template <
typename TYPE>
140 if (instance_ !=
nullptr) {
145template <
typename TYPE>
146template <
typename ... Args>
148 instance_ = std::move(makeOwnerPtr<TYPE>(std::forward<Args>(args)...));
Exception for null pointer dereference attempts.
Definition error.h:171
Unique ownership smart pointer with move semantics.
Definition ownerPtr.h:37
Thread-safe singleton pattern implementation with ownership management.
Definition singleton.h:25
singleton(singleton &&)=delete
Deleted move constructor to prevent moving.
singleton(const singleton &)=delete
Deleted copy constructor to prevent copying.
static void clear()
Clears the singleton instance.
Definition singleton.h:139
static bool exist()
Checks if the singleton instance exists.
Definition singleton.h:116
singleton & operator=(const singleton &)=delete
Deleted copy assignment operator to prevent copying.
static void reset(Args &&... args)
Resets the singleton instance with new arguments.
Definition singleton.h:147
static TYPE & instance()
Provides access to the singleton instance.
Definition singleton.h:131
singleton & operator=(singleton &&)=delete
Deleted move assignment operator to prevent moving.
static void init(Args &&... args)
Initializes the singleton instance with provided arguments.
Definition singleton.h:122
Exception for invalid parameter values.
Definition error.h:150
Main namespace for the project Original.
Definition algorithms.h:21
Exclusive-ownership smart pointer implementation.