diff options
author | prout <prout@yandex-team.ru> | 2022-02-10 16:49:42 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:49:42 +0300 |
commit | 7b7fa28b9099b7adca890459a699c6ba5eeff4ca (patch) | |
tree | cffe238e08f715008f864d223dd0db8fc1f92f9f /util/generic/singleton.h | |
parent | 0fd1998e1b2369f50fb694556f817d3c7fef10c8 (diff) | |
download | ydb-7b7fa28b9099b7adca890459a699c6ba5eeff4ca.tar.gz |
Restoring authorship annotation for <prout@yandex-team.ru>. Commit 1 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 f5fa047f5c9..ab6ff598794 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()); } |