ugmisc 0.2
Miscellaneous C++ header library
Loading...
Searching...
No Matches
typelist.hpp File Reference

Lists of types which may be used in some of the ugmisc templates where a single type would usually be used. More...

#include <type_traits>

Go to the source code of this file.

Classes

struct  ugmisc::flatten< T >
 Converts the template parameters into a type_list. More...

Typedefs

template<std::size_t I, class T>
using ugmisc::type_list_member
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<class... T>
using ugmisc::flatten_t = typename flatten<T...>::type
template<std::size_t From, std::size_t To, class T>
using ugmisc::type_list_slice = typename get_type_list_slice<From, To, T>::type
template<std::size_t From, std::size_t Count, class T>
using ugmisc::type_list_sized_slice = type_list_slice<From, From + Count, T>
template<std::size_t Count, class T>
using ugmisc::type_list_prefix = type_list_slice<0, Count, T>
template<std::size_t Count, class T>
using ugmisc::type_list_suffix = type_list_slice<T::size - Count, T::size, T>
template<std::size_t Count, class T>
using ugmisc::type_list_remove_prefix = type_list_slice<Count, T::size, T>
template<std::size_t Count, class T>
using ugmisc::type_list_remove_suffix = type_list_slice<0, T::size-Count, T>
template<std::size_t From, std::size_t To, class... T>
using ugmisc::flatten_slice = type_list_slice<From, To, flatten_t<T...>>
template<std::size_t From, std::size_t Count, class... T>
using ugmisc::flatten_sized_slice = type_list_sized_slice<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...>>

Detailed Description

Lists of types which may be used in some of the ugmisc templates where a single type would usually be used.

Why?

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.

Operations

Some operations are templates which come in two variants.

  • flatten_ prefixed template type aliases
  • type_list_ prefixed template type aliases

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 slices from type_lists, filtering out some of the members of a type_list, and concatenating two or more type_lists.

Typedef Documentation

◆ concatenate_type_lists_t

template<class... T>
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:

#include <type_traits>
using namespace ugmisc;
using B = type_list<>; // Empty list.
static_assert( std::is_same_v< all, type_list<int, float, char, int, int> > );
Definition typelist.hpp:69
Lists of types which may be used in some of the ugmisc templates where a single type would usually be...
typename concatenate_type_lists< T... >::type concatenate_type_lists_t
Definition typelist.hpp:194
Template Parameters
TEach type is an instance of type_list.

◆ flatten_prefix

template<std::size_t Count, class... T>
using ugmisc::flatten_prefix = type_list_prefix<Count, flatten_t<T...>>

◆ flatten_remove_prefix

template<std::size_t Count, class... T>
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.

See also
ugmisc::flatten_slice, ugmisc::type_list_remove_prefix.

◆ flatten_remove_suffix

template<std::size_t Count, class... T>
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.

See also
ugmisc::flatten_slice, ugmisc::type_list_remove_suffix.

◆ flatten_sized_slice

template<std::size_t From, std::size_t Count, class... T>
using ugmisc::flatten_sized_slice = type_list_sized_slice<From, Count, flatten_t<T...>>

◆ flatten_slice

template<std::size_t From, std::size_t To, class... T>
using ugmisc::flatten_slice = type_list_slice<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.

See also
ugmisc::type_list_slice.

◆ flatten_suffix

template<std::size_t Count, class... T>
using ugmisc::flatten_suffix = type_list_suffix<Count, flatten_t<T...>>

◆ type_list_member

template<std::size_t I, class T>
using ugmisc::type_list_member
Initial value:
typename get_type_list_member<I, T>::type

◆ type_list_prefix

template<std::size_t Count, class T>
using ugmisc::type_list_prefix = type_list_slice<0, Count, T>

Aliases an ugmisc::type_list with the first Count members of the type_list template parameter T.

See also
ugmisc::type_list_slice, ugmisc::type_list_suffix, ugmisc::flatten_prefix.

◆ type_list_remove_prefix

template<std::size_t Count, class T>
using ugmisc::type_list_remove_prefix = type_list_slice<Count, T::size, T>

Aliases an ugmisc::type_list with the first Count members of the type_list template parameter T removed.

See also
ugmisc::type_list_slice, ugmisc::flatten_remove_prefix.

◆ type_list_remove_suffix

template<std::size_t Count, class T>
using ugmisc::type_list_remove_suffix = type_list_slice<0, T::size-Count, T>

Aliases an ugmisc::type_list with the last Count members of the type_list template parameter T removed.

See also
ugmisc::type_list_slice, ugmisc::flatten_remove_suffix.

◆ type_list_sized_slice

template<std::size_t From, std::size_t Count, class T>
using ugmisc::type_list_sized_slice = type_list_slice<From, From + Count, T>

◆ type_list_slice

template<std::size_t From, std::size_t To, class T>
using ugmisc::type_list_slice = typename get_type_list_slice<From, To, T>::type
Template Parameters
TA 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.

See also
flatten_slice

◆ type_list_suffix

template<std::size_t Count, class T>
using ugmisc::type_list_suffix = type_list_slice<T::size - Count, T::size, T>

Aliases an ugmisc::type_list with the last Count members of the type_list template parameter T.

See also
ugmisc::type_list_slice, ugmisc::type_list_prefix, ugmisc::flatten_suffix.