OGLplus  (0.59.0) a C++ wrapper for rendering APIs

mp_list.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_MP_LIST_HPP
10 #define EAGINE_MP_LIST_HPP
11 
12 #include <type_traits>
13 
14 namespace eagine {
15 
19 template <typename... C>
20 struct mp_list {
22  using type = mp_list;
23 };
24 //------------------------------------------------------------------------------
28 template <typename TL>
29 struct mp_is_empty;
30 
34 template <typename TL>
35 constexpr const auto mp_is_empty_v = mp_is_empty<TL>::value;
36 
37 template <>
38 struct mp_is_empty<mp_list<>> : std::true_type {};
39 
40 template <typename... T>
41 struct mp_is_empty<mp_list<T...>> : std::false_type {};
42 //------------------------------------------------------------------------------
46 template <typename TL, typename T>
47 struct mp_contains;
48 
53 template <typename TL, typename T>
55 
60 template <typename TL, typename T>
62 
63 template <typename T>
64 struct mp_contains<mp_list<>, T> : std::false_type {};
65 
66 template <typename H, typename... C, typename T>
67 struct mp_contains<mp_list<H, C...>, T> : mp_contains<mp_list<C...>, T> {};
68 
69 template <typename... C, typename T>
70 struct mp_contains<mp_list<T, C...>, T> : std::true_type {};
71 //------------------------------------------------------------------------------
75 template <typename TL1, typename TL2, typename TL3>
76 struct mp_union_add;
77 
78 template <typename... T3>
79 struct mp_union_add<mp_list<>, mp_list<>, mp_list<T3...>> : mp_list<T3...> {};
80 
81 template <typename... T1, typename... T3>
82 struct mp_union_add<mp_list<T1...>, mp_list<>, mp_list<T3...>>
83  : mp_list<T3...> {};
84 
85 template <typename... T2, typename... T3>
86 struct mp_union_add<mp_list<>, mp_list<T2...>, mp_list<T3...>>
87  : mp_list<T3...> {};
88 
89 template <typename H, typename... T1, typename... T2, typename... T3>
90 struct mp_union_add<mp_list<H, T1...>, mp_list<T2...>, mp_list<T3...>>
91  : std::conditional_t<
92  mp_contains<mp_list<T2...>, H>::value,
93  mp_union_add<mp_list<T1...>, mp_list<T2...>, mp_list<T3..., H>>,
94  mp_union_add<mp_list<T1...>, mp_list<T2...>, mp_list<T3...>>> {};
95 
99 template <typename TL1, typename TL2>
101 
105 template <typename TL1, typename TL2>
107 //------------------------------------------------------------------------------
108 } // namespace eagine
109 
110 #endif // EAGINE_MP_LIST_HPP
Common code is placed in this namespace.
Definition: eagine.hpp:21
constexpr const auto mp_contains_v
Trait indicating whether a type list contains a specified type.
Definition: mp_list.hpp:54
typename mp_union< TL1, TL2 >::type mp_union_t
Trait returning the union of types in two type lists.
Definition: mp_list.hpp:106
Implements the contains operation on compile-time type lists.
Definition: mp_list.hpp:47
Implements the union operation on compile-time type lists.
Definition: mp_list.hpp:76
typename mp_contains< TL, T >::type mp_contains_t
Trait indicating whether a type list contains a specified type.
Definition: mp_list.hpp:61
Compile-time type list template.
Definition: mp_list.hpp:20
Implements the is_empty operation on compile-time type lists.
Definition: mp_list.hpp:29
constexpr const auto mp_is_empty_v
Trait indicating whether a type list is empty.
Definition: mp_list.hpp:35

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).