1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#pragma once
#include <type_traits>
#include <tuple>
namespace mbgl {
template <class... Ts>
struct TypeList {
template <template <class...> class T, class... Ps>
using ExpandInto = T<Ps..., Ts...>;
};
namespace detail {
template <class, class>
struct TypeCons;
template <class T, class... Ts>
struct TypeCons<T, TypeList<Ts...>> {
using Type = TypeList<T, Ts...>;
};
template <class, template <class> class>
struct TypeFilter;
template <template <class> class Predicate>
struct TypeFilter<TypeList<>, Predicate> {
using Type = TypeList<>;
};
template <template <class> class Predicate, class T, class... Ts>
struct TypeFilter<TypeList<T, Ts...>, Predicate> {
using Tail = typename TypeFilter<TypeList<Ts...>, Predicate>::Type;
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
|