Use a destructor instead of atexit() because the latter does not work properly when the singleton is in a library that is unloaded.
| 46 | // Use a destructor instead of atexit() because the latter does not work |
| 47 | // properly when the singleton is in a library that is unloaded. |
| 48 | ~singleton() |
| 49 | { |
| 50 | if (init_flag.load(std::memory_order_acquire)) |
| 51 | reinterpret_cast<T*>(&storage)->~T(); |
| 52 | } |
| 53 | |
| 54 | public: |
| 55 | static T& get_instance() |