Tatooine
type_set.h
Go to the documentation of this file.
1#ifndef TATOOINE_STATIC_SET_H
2#define TATOOINE_STATIC_SET_H
3//==============================================================================
5
6#include <type_traits>
7//==============================================================================
8namespace tatooine {
9//==============================================================================
20template <typename... Ts>
21struct type_set_impl;
22//==============================================================================
26//==============================================================================
28template <typename... Types>
30 : std::integral_constant<std::size_t, sizeof...(Types)> {};
31//==============================================================================
33//==============================================================================
37//==============================================================================
39template <typename... Types, std::size_t I>
40struct type_list_at_impl<type_set_impl<Types...>, I> {
41 using type = typename type_list_at_impl<type_list<Types...>, I>::type;
42};
43//==============================================================================
45//==============================================================================
49//==============================================================================
50template <typename... Ts, typename T>
52 static auto constexpr value =
53 type_list_contains_impl<type_list<Ts...>, T>::value;
54};
55//==============================================================================
57//==============================================================================
61//==============================================================================
62template <typename TypeList, typename NewType, typename... TypesAccumulator>
64//------------------------------------------------------------------------------
66template <typename SetHead, typename... SetRest, typename NewType,
67 typename... TypesAccumulator>
68struct type_set_insert_impl<type_list<SetHead, SetRest...>, NewType,
69 TypesAccumulator...> {
70 using type =
71 typename type_set_insert_impl<type_list<SetRest...>, NewType,
72 TypesAccumulator..., SetHead>::type;
73};
74// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
76template <typename SetHead, typename... SetRest, typename NewType,
77 typename... TypesAccumulator>
78struct type_set_insert_impl<type_set_impl<SetHead, SetRest...>, NewType,
79 TypesAccumulator...> {
80 using type =
81 typename type_set_insert_impl<type_set_impl<SetRest...>, NewType,
82 TypesAccumulator..., SetHead>::type;
83};
84//------------------------------------------------------------------------------
86template <typename SetHead, typename... SetRest, typename... TypesAccumulator>
87struct type_set_insert_impl<type_list<SetHead, SetRest...>, SetHead,
88 TypesAccumulator...> {
89 using type = type_list<TypesAccumulator..., SetHead, SetRest...>;
90};
91// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
93template <typename SetHead, typename... SetRest, typename... TypesAccumulator>
94struct type_set_insert_impl<type_set_impl<SetHead, SetRest...>, SetHead,
95 TypesAccumulator...> {
96 using type = type_set_impl<TypesAccumulator..., SetHead, SetRest...>;
97};
98//------------------------------------------------------------------------------
100template <typename NewType, typename... TypesAccumulator>
101struct type_set_insert_impl<type_list<>, NewType, TypesAccumulator...> {
102 using type = type_list<TypesAccumulator..., NewType>;
103};
104// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
105template <typename NewType, typename... TypesAccumulator>
106struct type_set_insert_impl<type_set_impl<>, NewType, TypesAccumulator...> {
107 using type = type_set_impl<TypesAccumulator..., NewType>;
108};
109//------------------------------------------------------------------------------
110template <typename TypeList, typename NewType>
113//==============================================================================
117template <typename TypeList, typename... Ts>
119//------------------------------------------------------------------------------
120template <typename TypeList, typename T, typename... Ts>
121struct type_set_constructor<TypeList, T, Ts...> {
122 using type =
124};
125//------------------------------------------------------------------------------
126template <typename ...Ts>
128 using type = type_set_impl<Ts...>;
129};
130//------------------------------------------------------------------------------
131template <typename... Ts>
132using type_set = typename type_set_constructor<type_list<>, Ts...>::type;
133//==============================================================================
135//==============================================================================
137template <typename... Ts>
138struct type_set_impl : type_list<Ts...> {
139 using this_type = type_set_impl<Ts...>;
140 template <typename T>
142};
143//==============================================================================
145//==============================================================================
146} // namespace tatooine
147//==============================================================================
148#endif
typename type_set_constructor< type_list<>, Ts... >::type type_set
Definition: type_set.h:132
typename type_set_insert_impl< TypeList, NewType >::type type_set_insert
Definition: type_set.h:111
Definition: algorithm.h:6
T type
Definition: common_type.h:13
typename type_list_at_impl< type_list< Types... >, I >::type type
Definition: type_set.h:41
Access to the Ith element of TypeList.
Definition: type_list.h:51
Definition: type_list.h:224
An empty struct that holds types.
Definition: type_list.h:248
Size of a tatooine::type_list_impl.
Definition: type_list.h:30
typename type_set_constructor< type_set_insert< TypeList, T >, Ts... >::type type
Definition: type_set.h:123
Definition: type_set.h:118
Inherits from a type_list with only unique types.
Definition: type_set.h:138
type_set_insert< this_type, T > insert
Definition: type_set.h:141
typename type_set_insert_impl< type_list< SetRest... >, NewType, TypesAccumulator..., SetHead >::type type
Definition: type_set.h:72
typename type_set_insert_impl< type_set_impl< SetRest... >, NewType, TypesAccumulator..., SetHead >::type type
Definition: type_set.h:82
Definition: type_set.h:63