Morpheus 1.0.0
Dynamic matrix type and algorithms for sparse matrices
Loading...
Searching...
No Matches
impl/Morpheus_Metaprogramming.hpp
1
24#ifndef MORPHEUS_IMPL_METAPROGRAMMING_HPP
25#define MORPHEUS_IMPL_METAPROGRAMMING_HPP
26
28namespace Morpheus {
29
30// Forward declarations
31template <typename... Ts>
32struct TypeList;
33template <typename... Ts>
34struct Set;
35template <class... Ts>
36struct IndexedTypeList;
37
38template <typename T, typename U>
39struct cross_product;
40template <typename... T>
41struct concat;
42
43namespace Impl {
44// forward decl
45template <typename T, typename U>
46struct cross_product;
47template <typename... T>
48struct concat;
49
50template <typename... Ts, typename... Us>
51struct concat<TypeList<Ts...>, TypeList<Us...>> {
52 using type = TypeList<Ts..., Us...>;
53};
54
55// Partially specialise the empty cases.
56template <typename... Us>
57struct cross_product<TypeList<>, TypeList<Us...>> {
58 using type = TypeList<>;
59};
60
61template <typename... Us>
62struct cross_product<TypeList<Us...>, TypeList<>> {
63 using type = TypeList<>;
64};
65
66template <>
67struct cross_product<TypeList<>, TypeList<>> {
68 using type = TypeList<>;
69};
70
71// Generic Case
72template <typename T, typename... Ts, typename U, typename... Us>
73struct cross_product<TypeList<T, Ts...>, TypeList<U, Us...>> {
74 using type = typename concat<
75 typename concat<
76 TypeList<Set<T, U>>,
77 typename cross_product<TypeList<T>, TypeList<Us...>>::type>::type,
78 typename cross_product<TypeList<Ts...>, TypeList<U, Us...>>::type>::type;
79};
80
86template <typename... T, typename... Ts, typename U, typename... Us>
87struct cross_product<TypeList<Set<T...>, Ts...>, TypeList<U, Us...>> {
88 using type = typename concat<
89 typename concat<TypeList<Set<T..., U>>,
90 typename cross_product<TypeList<Set<T...>>,
91 TypeList<Us...>>::type>::type,
92 typename cross_product<TypeList<Ts...>, TypeList<U, Us...>>::type>::type;
93};
94
100template <typename T, typename... Ts, typename... U, typename... Us>
101struct cross_product<TypeList<T, Ts...>, TypeList<Set<U...>, Us...>> {
102 using type = typename concat<
103 typename concat<
104 TypeList<Set<T, U...>>,
105 typename cross_product<TypeList<T>, TypeList<Us...>>::type>::type,
106 typename cross_product<TypeList<Ts...>,
107 TypeList<Set<U...>, Us...>>::type>::type;
108};
109
115template <typename... T, typename... Ts, typename... U, typename... Us>
116struct cross_product<TypeList<Set<T...>, Ts...>, TypeList<Set<U...>, Us...>> {
117 using type = typename concat<
118 typename concat<TypeList<Set<T..., U...>>,
119 typename cross_product<TypeList<Set<T...>>,
120 TypeList<Us...>>::type>::type,
121 typename cross_product<TypeList<Ts...>,
122 TypeList<Set<U...>, Us...>>::type>::type;
123};
124} // namespace Impl
125} // namespace Morpheus
127#endif // MORPHEUS_IMPL_METAPROGRAMMING_HPP
Generic Morpheus interfaces.
Definition: dummy.cpp:24