From af067d0db4190be4f0a308b76649425705bd03f4 Mon Sep 17 00:00:00 2001 From: sha512sum Date: Sat, 29 Jun 2024 08:45:28 +0000 Subject: [PATCH] Update Attributes --- examples/src/attributes.cpp | 4 +++- include/utempl/attributes.hpp | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/examples/src/attributes.cpp b/examples/src/attributes.cpp index e8ab25c..773e083 100644 --- a/examples/src/attributes.cpp +++ b/examples/src/attributes.cpp @@ -30,13 +30,15 @@ static_assert(utempl::GetAttributes() struct SomeOtherStruct { static_assert(utempl::OpenStruct()); utempl::FieldAttribute, int> field1; - utempl::FieldAttribute, void> field2; + utempl::FieldAttribute> field2; + utempl::FieldAttribute, void> field3; static_assert(utempl::CloseStruct()); }; static_assert(utempl::GetAttributes() == utempl::Tuple{ utempl::kTypeList, + utempl::NoInfo{}, utempl::kTypeList}); diff --git a/include/utempl/attributes.hpp b/include/utempl/attributes.hpp index ba61492..ff27d63 100644 --- a/include/utempl/attributes.hpp +++ b/include/utempl/attributes.hpp @@ -56,12 +56,23 @@ struct FieldType { namespace impl { +template +struct FieldAttributeData { + using Type = TypeList; +}; + +template <> +struct FieldAttributeData<> { + using Type = NoInfo; +}; + + template < typename T, typename... Ts, auto f = []{}, typename Current = decltype(GetCurrentTagType())::Type, - auto = AddTypeToTag, TypeList, decltype(f)>() + auto = AddTypeToTag, typename FieldAttributeData::Type, decltype(f)>() > consteval auto FieldAttribute() -> T::Type;