aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/memory/leaky_singleton-inl.h
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2023-05-05 16:05:59 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2023-05-05 16:05:59 +0300
commitcf23a0405e5beab06a2ebd6b4b9905631e97ab72 (patch)
tree73275fd12808e23205927203cd74c5afcefdd40e /library/cpp/yt/memory/leaky_singleton-inl.h
parentfa138a9ac750b5a8717395ca0b76e06366b864ec (diff)
downloadydb-cf23a0405e5beab06a2ebd6b4b9905631e97ab72.tar.gz
Intermediate changes
Diffstat (limited to 'library/cpp/yt/memory/leaky_singleton-inl.h')
-rw-r--r--library/cpp/yt/memory/leaky_singleton-inl.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/library/cpp/yt/memory/leaky_singleton-inl.h b/library/cpp/yt/memory/leaky_singleton-inl.h
index 932747c921..7a7b28a582 100644
--- a/library/cpp/yt/memory/leaky_singleton-inl.h
+++ b/library/cpp/yt/memory/leaky_singleton-inl.h
@@ -4,14 +4,17 @@
#include "leaky_singleton.h"
#endif
+#include <utility>
+
namespace NYT {
////////////////////////////////////////////////////////////////////////////////
template <class T>
-TLeakyStorage<T>::TLeakyStorage()
+template <class... TArgs>
+TLeakyStorage<T>::TLeakyStorage(TArgs&&... args)
{
- new (Get()) T();
+ new (Get()) T(std::forward<TArgs>(args)...);
}
template <class T>
@@ -22,10 +25,10 @@ T* TLeakyStorage<T>::Get()
////////////////////////////////////////////////////////////////////////////////
-template <class T>
-T* LeakySingleton()
+template <class T, class... TArgs>
+T* LeakySingleton(TArgs&&... args)
{
- static TLeakyStorage<T> Storage;
+ static TLeakyStorage<T> Storage(std::forward<TArgs>(args)...);
return Storage.Get();
}