13 #ifndef FOXXLL_SINGLETON_HEADER 14 #define FOXXLL_SINGLETON_HEADER 24 template <
typename InstanceType,
bool destroy_on_exit = true>
44 return create_instance<InstanceType>();
52 create_instance<InstanceType>();
58 template <
typename SubInstanceType>
72 template <
typename InstanceType,
bool destroy_on_exit>
73 template <
typename SubInstanceType>
86 template <
typename InstanceType,
bool destroy_on_exit>
95 template <
typename InstanceType,
bool destroy_on_exit>
99 template <
typename InstanceType,
bool destroy_on_exit>
104 #endif // !FOXXLL_SINGLETON_HEADER static std::mutex singleton_mutex_
mutex to protect instance_
static void destroy_instance()
destroy singleton and mark as invalid
volatile instance_pointer volatile_instance_pointer
instance_type * instance_pointer
static instance_pointer get_instance()
return instance or create base instance if empty
singleton & operator=(const singleton &)=delete
non-copyable: delete assignment operator
static instance_type & get_ref()
int register_exit_handler(void(*function)(void))
static volatile_instance_pointer instance_
singleton object instance
static instance_pointer create_instance()
create instance of SubInstanceType and move into singleton