Lists of types which may be used in some of the ugmisc templates where a single type would usually be used. More...
#include <cstddef>#include <limits>#include <type_traits>#include <utility>Go to the source code of this file.
Classes | |
| struct | ugmisc::is_type_list< T > |
| struct | ugmisc::wrapped_list< T > |
| struct | ugmisc::get_as_list< T > |
| struct | ugmisc::flatten< T > |
| struct | ugmisc::type_list< T > |
| Encapsulates a list of types. More... | |
Typedefs | |
| template<class... T> | |
| using | ugmisc::concatenate_type_lists_t = typename concatenate_type_lists<T...>::type |
| template<class T> | |
| using | ugmisc::get_as_list_t = typename get_as_list<T>::type |
| template<std::size_t I, class T> | |
| using | ugmisc::type_list_member |
| template<class T> | |
| using | ugmisc::type_list_from_tparams |
| template<class... T> | |
| using | ugmisc::flatten_t = typename flatten<T...>::type |
| Converts the template parameters into a type_list. | |
| template<std::size_t From, std::size_t To, class T> | |
| using | ugmisc::type_list_sublist = typename get_type_list_sublist<From, To, T>::type |
| template<std::size_t From, std::size_t Count, class T> | |
| using | ugmisc::type_list_sized_sublist = type_list_sublist<From, From + Count, T> |
| template<std::size_t Count, class T> | |
| using | ugmisc::type_list_prefix = type_list_sublist<0, Count, T> |
| template<std::size_t Count, class T> | |
| using | ugmisc::type_list_suffix = type_list_sublist<T::size - Count, T::size, T> |
| template<std::size_t Count, class T> | |
| using | ugmisc::type_list_remove_prefix = type_list_sublist<Count, T::size, T> |
| template<std::size_t Count, class T> | |
| using | ugmisc::type_list_remove_suffix = type_list_sublist<0, T::size-Count, T> |
| template<std::size_t From, std::size_t To, class... T> | |
| using | ugmisc::flatten_sublist = type_list_sublist<From, To, flatten_t<T...>> |
| template<std::size_t From, std::size_t Count, class... T> | |
| using | ugmisc::flatten_sized_sublist = type_list_sized_sublist<From, Count, flatten_t<T...>> |
| template<std::size_t Count, class... T> | |
| using | ugmisc::flatten_prefix = type_list_prefix<Count, flatten_t<T...>> |
| template<std::size_t Count, class... T> | |
| using | ugmisc::flatten_suffix = type_list_suffix<Count, flatten_t<T...>> |
| template<std::size_t Count, class... T> | |
| using | ugmisc::flatten_remove_prefix = type_list_remove_prefix<Count, flatten_t<T...>> |
| template<std::size_t Count, class... T> | |
| using | ugmisc::flatten_remove_suffix = type_list_remove_suffix<Count, flatten_t<T...>> |
| template<template< class > class Test, class T, test_modifier Mod = no_invert_test> | |
| using | ugmisc::type_list_filter |
| template<template< class > class Test, class T, test_modifier Mod = static_cast<test_modifier>(0)> | |
| using | ugmisc::filter_type_list = type_list_filter<Test, T, Mod> |
| template<template< class > class F, class T> | |
| using | ugmisc::type_list_apply_each_class = typename typelist_::apply_each<F, T>::class_types |
| template<template< class > class F, class T> | |
| using | ugmisc::type_list_apply_each = typename typelist_::apply_each<F, T>::inner_types |
| template<template< class > class F, class... T> | |
| using | ugmisc::flatten_apply_each_class = type_list_apply_each_class<F, flatten_t<T...>> |
| template<template< class > class F, class... T> | |
| using | ugmisc::flatten_apply_each = type_list_apply_each<F, flatten_t<T...>> |
| template<template< class > class Test, test_modifier Mod, class... T> | |
| using | ugmisc::flatten_filter = type_list_filter<Test, flatten_t<T...>, Mod> |
| template<std::ptrdiff_t Base, std::ptrdiff_t Stride, std::size_t Count, class T> | |
| using | ugmisc::type_list_stride |
| template<std::ptrdiff_t Base, std::ptrdiff_t Stride, std::size_t Count, class... T> | |
| using | ugmisc::flatten_stride = type_list_stride<Base, Stride, Count, flatten_t<T...>> |
Enumerations | |
| enum | ugmisc::test_modifier { ugmisc::no_invert_test , ugmisc::invert_test } |
Functions | |
| template<class T, class U> | |
| constexpr auto | ugmisc::operator+ (T, U) -> concatenate_type_lists_t< T, U > |
| template<class T, class U> | |
| constexpr auto | ugmisc::operator== (T, U) -> std::enable_if_t< is_type_list_v< T > &&is_type_list_v< U >, bool > |
| template<class T, class U> | |
| constexpr auto | ugmisc::operator!= (T, U) -> std::enable_if_t< is_type_list_v< T > &&is_type_list_v< U >, bool > |
Lists of types which may be used in some of the ugmisc templates where a single type would usually be used.
The member.hpp header finds this stuff useful. You might too.
List of types can be manipulated easily, as if they are lists of objects.
Some operations are templates which come in two variants.
The flatten_ variants are more flexible, and will always work as a drop in replacement for their type_list_ twins. That might not be what you want though. If you think you have an instance of the type_list<> template to pass to e.g. flatten_filter then using type_list_filter is effectively like doing the same thing but also making a static assertion that it is indeed a type_list.
Operations include adding and removing prefixes and suffixes or taking sublists from type_lists, filtering out some of the members of a type_list, and concatenating two or more type_lists.
An instance of the ugmisc::type_list template is an empty type with trivial constructors and destructor. It is possible to use objects of these types to perform operations, then take the type of the resulting object.
Definition in file typelist.hpp.
| using ugmisc::concatenate_type_lists_t = typename concatenate_type_lists<T...>::type |
Aliases a type which is a type_list containing all the member types of the template paramter type_list types.
For example:
| T | Each type is an instance of type_list. |
Definition at line 173 of file typelist.hpp.
| using ugmisc::filter_type_list = type_list_filter<Test, T, Mod> |
Definition at line 378 of file typelist.hpp.
| using ugmisc::flatten_apply_each = type_list_apply_each<F, flatten_t<T...>> |
Like type_list_apply_each, but creates a type list using flatten_t<T...>.
Definition at line 421 of file typelist.hpp.
| using ugmisc::flatten_apply_each_class = type_list_apply_each_class<F, flatten_t<T...>> |
Like type_list_apply_each_class, but creates a type list using flatten_t<T...>.
Definition at line 411 of file typelist.hpp.
| using ugmisc::flatten_filter = type_list_filter<Test, flatten_t<T...>, Mod> |
Definition at line 432 of file typelist.hpp.
| using ugmisc::flatten_prefix = type_list_prefix<Count, flatten_t<T...>> |
Definition at line 317 of file typelist.hpp.
| using ugmisc::flatten_remove_prefix = type_list_remove_prefix<Count, flatten_t<T...>> |
Aliases an ugmisc::type_list with the first Count members of the parameter types T removed.
Definition at line 332 of file typelist.hpp.
| using ugmisc::flatten_remove_suffix = type_list_remove_suffix<Count, flatten_t<T...>> |
Aliases an ugmisc::type_list with the last Count members of the template parameter types T removed.
Definition at line 341 of file typelist.hpp.
| using ugmisc::flatten_sized_sublist = type_list_sized_sublist<From, Count, flatten_t<T...>> |
Definition at line 311 of file typelist.hpp.
| using ugmisc::flatten_stride = type_list_stride<Base, Stride, Count, flatten_t<T...>> |
Like type_list_stride, but passes flatten_t<T...> as the type_list template parameter.
Definition at line 507 of file typelist.hpp.
| using ugmisc::flatten_sublist = type_list_sublist<From, To, flatten_t<T...>> |
Creates an ugmisc::type_alias. Uses the From'th element of the list of types T, and all types up to but not including the To'th element.
Definition at line 305 of file typelist.hpp.
| using ugmisc::flatten_suffix = type_list_suffix<Count, flatten_t<T...>> |
Definition at line 323 of file typelist.hpp.
| using ugmisc::flatten_t = typename flatten<T...>::type |
Converts the template parameters into a type_list.
Every parameter which is itself a type_list is unrolled. Every wrapped_list is unwrapped (but not recursively).
So for example:
flatten_t< typelist<A, B>, C, wrapped_list<typelist<D, E, F> >
is the type:
typelist<A, B, C, typelist<D, E, F> >
The implementation uses some single-arg template specializations to distinguish between template args which are type_list, wrapped_list, or neither. Then the non-specialised flatten concatenates the types produced by those.
A wrapped_list should be unwrapped once, whereas a type_list should be unwrapped recursively.
Definition at line 239 of file typelist.hpp.
| using ugmisc::get_as_list_t = typename get_as_list<T>::type |
Definition at line 177 of file typelist.hpp.
| using ugmisc::type_list_apply_each = typename typelist_::apply_each<F, T>::inner_types |
Given a type T which is an instance of type_list type_list<U...>, this template type alias is a type type_list<typename F<U>::type...>.
Definition at line 400 of file typelist.hpp.
| using ugmisc::type_list_apply_each_class = typename typelist_::apply_each<F, T>::class_types |
Given a type T which is an instance of type_list type_list<U...>, this template type alias is a type type_list<F<U>...>.
Definition at line 390 of file typelist.hpp.
| using ugmisc::type_list_filter |
Aliases a type_list instance only containing those member types which pass a test.
| T | A type_list. |
| Test | A template, such that Test<T>::value exists and can be implicitly converted to bool. If the value is true, T is included in the aliased type_list. |
| Mod | Set this to ugmisc::invert_test to reverse the result of each application of the test. This means that if Test<T>::value is false the type T is included in the result. |
Definition at line 365 of file typelist.hpp.
| using ugmisc::type_list_from_tparams |
Given a template F, and types U..., if T is F<U...>, this aliases ugmisc::type_list<U...>.
Given a template F, type I, and values V of type I, if T is F<I, V...>, this aliases ugmisc::type_list<std::integral_constant<I, V>...>.
Otherwise, the alias is not valid.
Definition at line 211 of file typelist.hpp.
| using ugmisc::type_list_member |
The type at an index of a typelist.
| I | The zero based index. |
| T | An instance of the type_list class template. |
Definition at line 195 of file typelist.hpp.
| using ugmisc::type_list_prefix = type_list_sublist<0, Count, T> |
Aliases an ugmisc::type_list with the first Count members of the type_list template parameter T.
Definition at line 268 of file typelist.hpp.
| using ugmisc::type_list_remove_prefix = type_list_sublist<Count, T::size, T> |
Aliases an ugmisc::type_list with the first Count members of the type_list template parameter T removed.
Definition at line 286 of file typelist.hpp.
| using ugmisc::type_list_remove_suffix = type_list_sublist<0, T::size-Count, T> |
Aliases an ugmisc::type_list with the last Count members of the type_list template parameter T removed.
Definition at line 295 of file typelist.hpp.
| using ugmisc::type_list_sized_sublist = type_list_sublist<From, From + Count, T> |
Definition at line 259 of file typelist.hpp.
| using ugmisc::type_list_stride |
Creates a type list by starting from any part of the type list T and taking steps of zero or more elements.
| Base | The index in T which is used as the first element of the new type_list. |
| Stride | Each new element of the new type list is taken by taking Stride steps along the elements of T. Use a negative value to step backward. |
| Count | The number of elements in the new type list. |
| T | An instance of the type_list template. |
For example:
Definition at line 493 of file typelist.hpp.
| using ugmisc::type_list_sublist = typename get_type_list_sublist<From, To, T>::type |
| T | A type_list. |
Takes the types from the From index up to but not including the To index, and turns them into an ugmisc::type_list.
Definition at line 253 of file typelist.hpp.
| using ugmisc::type_list_suffix = type_list_sublist<T::size - Count, T::size, T> |
Aliases an ugmisc::type_list with the last Count members of the type_list template parameter T.
Definition at line 277 of file typelist.hpp.
| Enumerator | |
|---|---|
| no_invert_test | Keep types when the Filter returns true. |
| invert_test | Keep types when the Filter returns false. |
Definition at line 91 of file typelist.hpp.
|
constexpr |
Definition at line 1135 of file typelist.hpp.
|
constexpr |
Concatenate type lists, using instances of the type lists. A type list is a type, not an object. However, it can be instantiated, and is a trivial empty class.
Instances can be added, and the resulting object is an instance of the type that would be produced by concatenating the two type lists.
Definition at line 1119 of file typelist.hpp.
|
constexpr |
type_list objects compare equal if they have the exact same type
Definition at line 1128 of file typelist.hpp.