| 1 | // -*- C++ -*-cxx . . $ `<file>/vendor/Heap-Layers/utility/singleton.h`/ |
| 2 | |
| 3 | #ifndef HL_SINGLETON_H |
| 4 | #define HL_SINGLETON_Hcxx . . $ `vendor/Heap-Layers/utility/singleton.h:4:9`! |
| 5 | |
| 6 | #include <new> |
| 7 | |
| 8 | namespace HLcxx . . $ HL/ { |
| 9 | |
| 10 | template <class C> |
| 11 | class singletoncxx . . $ HL/singleton# { |
| 12 | public: |
| 13 | |
| 14 | static C& getInstancecxx . . $ HL/singleton#getInstance(19b2b6f17af048b).() { |
| 15 | #if 0 |
| 16 | static C theSingleton; |
| 17 | return theSingleton; |
| 18 | #else |
| 19 | // This is used with heaps, and when a heap replaces the system heap it needs |
| 20 | // to continue existing past global destructor invocation, as it may be called |
| 21 | // from atexit(), etc. |
| 22 | alignas(stdcxx . . $ std/::max_align_t) static char buf[sizeof(C)]; |
| 23 | static C * theSingleton = new (buf) C; |
| 24 | return *theSingleton; |
| 25 | #endif |
| 26 | } |
| 27 | |
| 28 | singletoncxx . . $ HL/singleton#`singleton<C>`(49f6e7a06ebc5aa8).()= default; |
| 29 | ~cxx . . $ HL/singleton#`~singleton<C>`(49f6e7a06ebc5aa8).singleton()= default; |
| 30 | singletoncxx . . $ HL/singleton#`singleton<C>`(9219865f77b1aa04).(const singleton&)= delete; |
| 31 | singleton& operatorcxx . . $ HL/singleton#`operator=`(e490195fe4c93d28).=(const singleton&)= delete; |
| 32 | }; |
| 33 | |
| 34 | } |
| 35 | |
| 36 | #endif |
| 37 |