Add Tag to meta info

This commit is contained in:
sha512sum 2024-04-17 23:21:15 +00:00
parent 219233d846
commit d84161f18f

View file

@ -11,28 +11,26 @@ struct Types {};
} // namespace impl
template <std::size_t Id>
struct MetaInfoKey {
};
template <std::size_t Id, typename Tag>
struct MetaInfoKey {};
template <typename T>
template <typename T, typename Tag = impl::Types>
struct MetaInfo {
static constexpr std::size_t kTypeId = loopholes::Counter<impl::Types, T>();
static constexpr std::size_t kTypeId = loopholes::Counter<Tag, T>();
using Type = T;
private:
static constexpr auto _ = loopholes::Injector<MetaInfoKey<kTypeId>{}, TypeList<T>{}>{};
static constexpr auto _ = loopholes::Injector<MetaInfoKey<kTypeId, Tag>{}, TypeList<T>{}>{};
};
template <typename T>
inline constexpr std::size_t kTypeId = MetaInfo<T>::kTypeId;
template <typename T, typename Tag = impl::Types>
inline constexpr std::size_t kTypeId = MetaInfo<T, Tag>::kTypeId;
template <std::size_t Id>
using GetMetaInfo = MetaInfo<typename decltype(Magic(loopholes::Getter<MetaInfoKey<Id>{}>{}))::Type>;
template <std::size_t Id, typename Tag = impl::Types>
using GetMetaInfo = MetaInfo<typename decltype(Magic(loopholes::Getter<MetaInfoKey<Id, Tag>{}>{}))::Type>;
template <std::size_t Id>
using GetType = GetMetaInfo<Id>::Type;
template <std::size_t Id, typename Tag = impl::Types>
using GetType = GetMetaInfo<Id, Tag>::Type;
} // namespace utempl