Add Tag to meta info
This commit is contained in:
parent
219233d846
commit
d84161f18f
1 changed files with 11 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue