#ifndef LEAKY_SINGLETON_INL_H_ #error "Direct inclusion of this file is not allowed, include leaky_singleton.h" // For the sake of sane code completion. #include "leaky_singleton.h" #endif #ifdef _asan_enabled_ #include #endif #include namespace NYT { //////////////////////////////////////////////////////////////////////////////// template template TLeakyStorage::TLeakyStorage(TArgs&&... args) { #ifdef _asan_enabled_ __lsan_disable(); #endif new (Get()) T(std::forward(args)...); #ifdef _asan_enabled_ __lsan_enable(); #endif } template T* TLeakyStorage::Get() { return reinterpret_cast(Buffer_); } //////////////////////////////////////////////////////////////////////////////// template T* LeakySingleton(TArgs&&... args) { static TLeakyStorage Storage(std::forward(args)...); return Storage.Get(); } //////////////////////////////////////////////////////////////////////////////// } // namespace NYT