aboutsummaryrefslogtreecommitdiffstats
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
parentfa138a9ac750b5a8717395ca0b76e06366b864ec (diff)
downloadydb-cf23a0405e5beab06a2ebd6b4b9905631e97ab72.tar.gz
Intermediate changes
-rw-r--r--library/cpp/yt/memory/leaky_singleton-inl.h13
-rw-r--r--library/cpp/yt/memory/leaky_singleton.h7
2 files changed, 12 insertions, 8 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();
}
diff --git a/library/cpp/yt/memory/leaky_singleton.h b/library/cpp/yt/memory/leaky_singleton.h
index 03b5e51d78..ebcfa24652 100644
--- a/library/cpp/yt/memory/leaky_singleton.h
+++ b/library/cpp/yt/memory/leaky_singleton.h
@@ -8,7 +8,8 @@ template <class T>
class TLeakyStorage
{
public:
- TLeakyStorage();
+ template <class... TArgs>
+ explicit TLeakyStorage(TArgs&&... args);
T* Get();
@@ -22,8 +23,8 @@ private:
template <class T> \
friend class ::NYT::TLeakyStorage;
-template <class T>
-T* LeakySingleton();
+template <class T, class... TArgs>
+T* LeakySingleton(TArgs&&... args);
////////////////////////////////////////////////////////////////////////////////