#pragma once #include #include namespace AK { template class NeverDestroyed { AK_MAKE_NONCOPYABLE(NeverDestroyed) AK_MAKE_NONMOVABLE(NeverDestroyed) public: template NeverDestroyed(Args... args) { new (storage) T(forward(args)...); } ~NeverDestroyed() = default; T* operator->() { return &get(); } const T* operator->() const { return &get(); } T& operator*() { return get(); } const T* operator*() const { return get(); } T& get() { return reinterpret_cast(storage); } const T& get() const { return reinterpret_cast(storage); } private: alignas(T) u8 storage[sizeof(T)]; }; } using AK::NeverDestroyed;