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 } // namespace impl
template <std::size_t Id> template <std::size_t Id, typename Tag>
struct MetaInfoKey { struct MetaInfoKey {};
};
template <typename T> template <typename T, typename Tag = impl::Types>
struct MetaInfo { 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; using Type = T;
private: private:
static constexpr auto _ = loopholes::Injector<MetaInfoKey<kTypeId>{}, TypeList<T>{}>{}; static constexpr auto _ = loopholes::Injector<MetaInfoKey<kTypeId, Tag>{}, TypeList<T>{}>{};
}; };
template <typename T> template <typename T, typename Tag = impl::Types>
inline constexpr std::size_t kTypeId = MetaInfo<T>::kTypeId; inline constexpr std::size_t kTypeId = MetaInfo<T, Tag>::kTypeId;
template <std::size_t Id> template <std::size_t Id, typename Tag = impl::Types>
using GetMetaInfo = MetaInfo<typename decltype(Magic(loopholes::Getter<MetaInfoKey<Id>{}>{}))::Type>; using GetMetaInfo = MetaInfo<typename decltype(Magic(loopholes::Getter<MetaInfoKey<Id, Tag>{}>{}))::Type>;
template <std::size_t Id> template <std::size_t Id, typename Tag = impl::Types>
using GetType = GetMetaInfo<Id>::Type; using GetType = GetMetaInfo<Id, Tag>::Type;
} // namespace utempl } // namespace utempl