#include <muu/type_list.h>
template <typename... T>
type_list struct
A 'tag' type for encoding/parameterizing lists of types (without the instantiation heft of std::
Template parameters | |
---|---|
T | The list of types represented by the list. |
This type is not simply std::
Public types
-
template <typename... U>using append = muu::
type_list<T..., U...> - Creates a new type list by appending types to this one.
-
using first =
/* ... */
- The first type in the list.
-
using flatten =
/* ... */
- A flattened version of the list with any nested type_lists recursively hoisted up into itself.
-
template <typename... U>using prepend = muu::
type_list<U..., T...> - Creates a new type list by prepending types to this one.
-
template <typename U>using remove =
/* ... */
- A version of the list with all ocurrences of the named type removed.
-
template <size_t Index>using select =
/* ... */
- Selects a single type from the list.
-
using slice =
/* ... */
- Selects a slice of types from the list.
- using type = first
- Alias for first when
length == 1
.
Public static variables
Typedef documentation
template <typename... T>
template <typename... U>
using muu::type_list::append = muu:: type_list<T..., U...>
template <typename... U>
Creates a new type list by appending types to this one.
static_assert(std::is_same_v< muu::type_list<int, float, char>::append<double, void, bool>, muu::type_list<int, float, char, double, void, bool> >);
template <typename... T>
using muu::type_list::first = /* ... */
The first type in the list.
using first_type = muu::type_list<int, float, char, void>::first; std::cout << "is int: " << std::is_same_v<first_type, int> << "\n"; std::cout << "is float: " << std::is_same_v<first_type, float> << "\n"; std::cout << "is char: " << std::is_same_v<first_type, char> << "\n"; std::cout << "is void: " << std::is_same_v<first_type, void> << "\n";
is int: true is float: false is char: false is void: false
template <typename... T>
using muu::type_list::flatten = /* ... */
A flattened version of the list with any nested type_lists recursively hoisted up into itself.
static_assert(std::is_same_v< muu::type_list<int, float, muu::type_list<muu::type_list<double>>>::flatten, muu::type_list<int, float, double> >);
template <typename... T>
template <typename... U>
using muu::type_list::prepend = muu:: type_list<U..., T...>
template <typename... U>
Creates a new type list by prepending types to this one.
static_assert(std::is_same_v< muu::type_list<int, float, char>::prepend<double, void, bool>, muu::type_list<double, void, bool, int, float, char> >);
template <typename... T>
template <typename U>
using muu::type_list::remove = /* ... */
template <typename U>
A version of the list with all ocurrences of the named type removed.
static_assert(std::is_same_v< muu::type_list<int, float, char, void, double, void>::remove<void>, muu::type_list<int, float, char, double> >);
using muu::type_list::select = /* ... */
Selects a single type from the list.
using selected_type = muu::type_list<int, float, char, void>::select<2>; std::cout << "is int: " << std::is_same_v<selected_type, int> << "\n"; std::cout << "is float: " << std::is_same_v<selected_type, float> << "\n"; std::cout << "is char: " << std::is_same_v<selected_type, char> << "\n"; std::cout << "is void: " << std::is_same_v<selected_type, void> << "\n";
is int: false is float: false is char: true is void: false