Update Attributes

This commit is contained in:
sha512sum 2024-06-29 08:45:28 +00:00
parent d367f13d7b
commit af067d0db4
2 changed files with 15 additions and 2 deletions

View file

@ -30,13 +30,15 @@ static_assert(utempl::GetAttributes<SomeStruct>()
struct SomeOtherStruct {
static_assert(utempl::OpenStruct<SomeOtherStruct>());
utempl::FieldAttribute<utempl::FieldType<int>, int> field1;
utempl::FieldAttribute<utempl::FieldType<int>, void> field2;
utempl::FieldAttribute<utempl::FieldType<int>> field2;
utempl::FieldAttribute<utempl::FieldType<std::string>, void> field3;
static_assert(utempl::CloseStruct());
};
static_assert(utempl::GetAttributes<SomeOtherStruct>()
== utempl::Tuple{
utempl::kTypeList<int>,
utempl::NoInfo{},
utempl::kTypeList<void>});

View file

@ -56,12 +56,23 @@ struct FieldType {
namespace impl {
template <typename... Ts>
struct FieldAttributeData {
using Type = TypeList<Ts...>;
};
template <>
struct FieldAttributeData<> {
using Type = NoInfo;
};
template <
typename T,
typename... Ts,
auto f = []{},
typename Current = decltype(GetCurrentTagType<impl::AttributesTag, decltype(f)>())::Type,
auto = AddTypeToTag<impl::AttributesCounterTag<Current>, TypeList<Ts...>, decltype(f)>()
auto = AddTypeToTag<impl::AttributesCounterTag<Current>, typename FieldAttributeData<Ts...>::Type, decltype(f)>()
>
consteval auto FieldAttribute() -> T::Type;