[core] introduce TypeListConcat and TypeList::ExpandInto

This commit is contained in:
Konstantin Käfer
2018-06-01 11:49:15 +02:00
committed by Molly Lloyd
parent 748e6bde5f
commit 5e9bbfdd44
6 changed files with 36 additions and 46 deletions

View File

@@ -5,8 +5,11 @@
namespace mbgl {
template <class...>
class TypeList {};
template <class... Ts>
struct TypeList {
template <template <class...> class T, class... Ps>
using ExpandInto = T<Ps..., Ts...>;
};
namespace detail {
@@ -32,9 +35,30 @@ struct TypeFilter<TypeList<T, Ts...>, Predicate> {
using Type = std::conditional_t<Predicate<T>::value, typename TypeCons<T, Tail>::Type, Tail>;
};
template <class...>
struct TypeListConcat;
template <>
struct TypeListConcat<> {
using Type = TypeList<>;
};
template <class... As>
struct TypeListConcat<TypeList<As...>> {
using Type = TypeList<As...>;
};
template <class... As, class... Bs, class... Rs>
struct TypeListConcat<TypeList<As...>, TypeList<Bs...>, Rs...> {
using Type = typename TypeListConcat<TypeList<As..., Bs...>, Rs...>::Type;
};
} // namespace detail
template <class TypeList, template <class> class Predicate>
using FilteredTypeList = typename detail::TypeFilter<TypeList, Predicate>::Type;
template <class... Ts>
using TypeListConcat = typename detail::TypeListConcat<Ts...>::Type;
} // namespace mbgl