diff options
author | prout <prout@yandex-team.ru> | 2022-02-10 16:49:43 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:43 +0300 |
commit | d2247f243d31adde8feb765324e40c83c5a90999 (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /util/generic/singleton.h | |
parent | 7b7fa28b9099b7adca890459a699c6ba5eeff4ca (diff) | |
download | ydb-d2247f243d31adde8feb765324e40c83c5a90999.tar.gz |
Restoring authorship annotation for <prout@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic/singleton.h')
-rw-r--r-- | util/generic/singleton.h | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/util/generic/singleton.h b/util/generic/singleton.h index ab6ff598794..f5fa047f5c9 100644 --- a/util/generic/singleton.h +++ b/util/generic/singleton.h @@ -56,7 +56,7 @@ namespace NPrivate { return ret; } - + template <class T, size_t P, class... TArgs> T* SingletonInt(TArgs&&... args) { static_assert(sizeof(T) < 32000, "use HugeSingleton instead"); @@ -71,22 +71,22 @@ namespace NPrivate { return ret; } - template <class T> - class TDefault { - public: + template <class T> + class TDefault { + public: template <class... TArgs> inline TDefault(TArgs&&... args) : T_(std::forward<TArgs>(args)...) - { - } - + { + } + inline const T* Get() const noexcept { - return &T_; - } - - private: - T T_; - }; + return &T_; + } + + private: + T T_; + }; template <class T> struct THeapStore { @@ -130,7 +130,7 @@ T* HugeSingletonWithPriority(TArgs&&... args) { return SingletonWithPriority<::NPrivate::THeapStore<T>, P>(std::forward<TArgs>(args)...)->D; } -template <class T> -const T& Default() { +template <class T> +const T& Default() { return *(::NPrivate::SingletonInt<typename ::NPrivate::TDefault<T>, TSingletonTraits<T>::Priority>()->Get()); } |