Gaia-ECS v1.0.0
A simple and powerful entity component system
Loading...
Searching...
No Matches
dyn_singleton.h
1#pragma once
2
3namespace gaia {
4 namespace core {
28 template <typename T>
29 class dyn_singleton final {
30 T* m_obj = new T();
31
32 dyn_singleton() = default;
33
34 public:
37 static T& get() noexcept {
38 static dyn_singleton<T> singleton;
39 return *singleton.m_obj;
40 }
41
42 dyn_singleton(dyn_singleton&& world) = delete;
43 dyn_singleton(const dyn_singleton& world) = delete;
44 dyn_singleton& operator=(dyn_singleton&&) = delete;
45 dyn_singleton& operator=(const dyn_singleton&) = delete;
46
48 get().done();
49 }
50 };
51 } // namespace core
52} // namespace gaia
Gaia-ECS is a header-only library which means we want to avoid using global static variables because ...
Definition dyn_singleton.h:29
static T & get() noexcept
Returns the process-wide singleton object.
Definition dyn_singleton.h:37