diff options
author | arkady-e1ppa <arkady-e1ppa@yandex-team.com> | 2024-06-11 09:52:50 +0300 |
---|---|---|
committer | arkady-e1ppa <arkady-e1ppa@yandex-team.com> | 2024-06-11 10:11:10 +0300 |
commit | 493d9816e749405ffbfa68ed5dcc2eb458747a39 (patch) | |
tree | 4abe0ee6d45a607df8eb6c61540323f432642ec5 | |
parent | 72cd1bd2a9b1c94a08343c8a8e21e6af4037ce28 (diff) | |
download | ydb-493d9816e749405ffbfa68ed5dcc2eb458747a39.tar.gz |
Allow external serialization of non-literal types
ca955bf8d04299fabe9f3ab001fe331440fe3a2b
-rw-r--r-- | yt/yt/core/ytree/unittests/yson_struct_ut.cpp | 21 | ||||
-rw-r--r-- | yt/yt/core/ytree/yson_struct-inl.h | 2 | ||||
-rw-r--r-- | yt/yt/core/ytree/yson_struct_public.h | 4 |
3 files changed, 24 insertions, 3 deletions
diff --git a/yt/yt/core/ytree/unittests/yson_struct_ut.cpp b/yt/yt/core/ytree/unittests/yson_struct_ut.cpp index 0337b098be..9636396ac5 100644 --- a/yt/yt/core/ytree/unittests/yson_struct_ut.cpp +++ b/yt/yt/core/ytree/unittests/yson_struct_ut.cpp @@ -1758,6 +1758,27 @@ TEST(TYsonStructTest, TestOptionalNoInit) //////////////////////////////////////////////////////////////////////////////// +struct TTestNonLiteralStruct +{ + TTestNonLiteralStruct() + { } +}; + +class TTestNonLiteralStructSerializer + : public virtual TExternalizedYsonStruct +{ + REGISTER_EXTERNALIZED_YSON_STRUCT(TTestNonLiteralStruct, TTestNonLiteralStructSerializer); + + static void Register(TRegistrar) + { } +}; + +ASSIGN_EXTERNAL_YSON_SERIALIZER(TTestNonLiteralStruct, TTestNonLiteralStructSerializer); + +static_assert(CExternallySerializable<TTestNonLiteralStruct>); + +//////////////////////////////////////////////////////////////////////////////// + struct TTestTraitConfig { int Field1; diff --git a/yt/yt/core/ytree/yson_struct-inl.h b/yt/yt/core/ytree/yson_struct-inl.h index baa01de7b5..cb1cb90562 100644 --- a/yt/yt/core/ytree/yson_struct-inl.h +++ b/yt/yt/core/ytree/yson_struct-inl.h @@ -552,7 +552,7 @@ public: \ YSON_STRUCT_EXTERNAL_SERIALIZER_IMPL__DECLARE_ALIASES(TStruct, TSerializer) \ #define ASSIGN_EXTERNAL_YSON_SERIALIZER(TStruct, TSerializer) \ - [[maybe_unused]] constexpr auto GetExternalizedYsonStructTraits(TStruct) \ + [[maybe_unused]] constexpr auto GetExternalizedYsonStructTraits(TStruct*) \ { \ struct [[maybe_unused]] TTraits \ { \ diff --git a/yt/yt/core/ytree/yson_struct_public.h b/yt/yt/core/ytree/yson_struct_public.h index 495a47b46f..40d3db7319 100644 --- a/yt/yt/core/ytree/yson_struct_public.h +++ b/yt/yt/core/ytree/yson_struct_public.h @@ -24,12 +24,12 @@ concept CExternalizedYsonStructTraits = requires { }; template <class T> -concept CExternallySerializable = requires (T t) { +concept CExternallySerializable = requires (T* t) { { GetExternalizedYsonStructTraits(t) } -> CExternalizedYsonStructTraits; }; template <CExternallySerializable T> -using TGetExternalizedYsonStructTraits = decltype(GetExternalizedYsonStructTraits(std::declval<T>())); +using TGetExternalizedYsonStructTraits = decltype(GetExternalizedYsonStructTraits(std::declval<T*>())); //////////////////////////////////////////////////////////////////////////////// |