Provides seqan3::type_list and metaprogramming utilities for working on type lists. More...
Namespaces | |
namespace | seqan3::list_traits |
Namespace containing traits for working on seqan3::type_list. | |
Classes | |
struct | seqan3::type_list< types > |
Type that contains multiple types. More... | |
struct | seqan3::detail::type_list_expander< type_list_t< args_t... > > |
Helper class to invoke a meta algorithm on the types contained in a seqan3::type_list. More... | |
Functions | |
template<typename type_list_t , typename unary_predicate_t > | |
constexpr bool | seqan3::detail::all_of (unary_predicate_t &&fn) |
Tests whether a given predicate evaluates to true for each type in a seqan3::type_list. More... | |
template<typename ... pack1_t, typename ... pack2_t, typename ... more_lists_t> | |
auto | seqan3::list_traits::detail::concat (type_list< pack1_t... >, type_list< pack2_t... >, more_lists_t ...) |
Implementation for seqan3::list_traits::concat [overload for more than two lists]. More... | |
template<typename ... pack_t> | |
pack_traits::drop_front< pack_t... > | seqan3::list_traits::detail::drop_front (type_list< pack_t... >) |
Implementation for seqan3::list_traits::drop_front. More... | |
template<typename type_list_t , typename unary_function_t > | |
constexpr void | seqan3::detail::for_each (unary_function_t &&fn) |
Applies a function element wise to all types of a type list. More... | |
template<typename replace_t , ptrdiff_t idx, typename ... pack_t> | |
pack_traits::replace_at< replace_t, idx, pack_t... > | seqan3::list_traits::detail::replace_at (type_list< pack_t... >) |
Implementation for seqan3::list_traits::replace_at. More... | |
template<ptrdiff_t idx, typename ... pack1_t> | |
pack_traits::split_after< idx, pack1_t... > | seqan3::list_traits::detail::split_after (type_list< pack1_t... >) |
Implementation for seqan3::list_traits::split_after. More... | |
Variables | |
template<ptrdiff_t idx, typename ... pack_t> | |
std::type_identity< seqan3::pack_traits::at< idx, pack_t... > > | seqan3::list_traits::detail::at (type_list< pack_t... >) |
Implementation for seqan3::list_traits::at. More... | |
template<typename ... pack_t> | |
std::type_identity< seqan3::pack_traits::back< pack_t... > > | seqan3::list_traits::detail::back (type_list< pack_t... >) |
Implementation for seqan3::list_traits::back. More... | |
template<typename ... pack1_t, typename ... pack2_t> | |
type_list< pack1_t..., pack2_t... > | seqan3::list_traits::detail::concat (type_list< pack1_t... >, type_list< pack2_t... >) |
Implementation for seqan3::list_traits::concat. More... | |
template<typename ... pack_t> | |
std::type_identity< seqan3::pack_traits::front< pack_t... > > | seqan3::list_traits::detail::front (type_list< pack_t... >) |
Implementation for seqan3::list_traits::front. More... | |
template<template< typename > typename trait_t, typename ... pack_t> | |
pack_traits::transform< trait_t, pack_t... > | seqan3::list_traits::detail::transform (type_list< pack_t... >) |
Implementation for seqan3::list_traits::transform. More... | |
Type list traits (return a single type) | |
template<ptrdiff_t idx, typename list_t > | |
using | seqan3::list_traits::at = typename decltype(detail::at< idx >(list_t{}))::type |
Return the type at given index from the type list. More... | |
template<typename list_t > | |
using | seqan3::list_traits::front = typename decltype(detail::front(list_t{}))::type |
Return the first type from the type list. More... | |
template<typename list_t > | |
using | seqan3::list_traits::back = typename decltype(detail::back(list_t{}))::type |
Return the last type from the type list. More... | |
Type list traits (return a type list) | |
template<typename ... lists_t> | |
using | seqan3::list_traits::concat = decltype(detail::concat(lists_t{}...)) |
Join two seqan3::type_list s into one. More... | |
template<typename list_t > | |
using | seqan3::list_traits::drop_front = decltype(detail::drop_front(list_t{})) |
Return a seqan3::type_list of all the types in the type list, except the first. More... | |
template<ptrdiff_t i, typename list_t > | |
using | seqan3::list_traits::take = typename decltype(detail::split_after< i >(list_t{}))::first_type |
Return a seqan3::type_list of the first n types in the input type list. More... | |
template<ptrdiff_t i, typename list_t > | |
using | seqan3::list_traits::drop = typename decltype(detail::split_after< i >(list_t{}))::second_type |
Return a seqan3::type_list of the types in the input type list, except the first n . More... | |
template<ptrdiff_t i, typename list_t > | |
using | seqan3::list_traits::take_last = drop< size< list_t > - i, list_t > |
Return a seqan3::type_list of the last n types in the input type list. More... | |
template<ptrdiff_t i, typename list_t > | |
using | seqan3::list_traits::drop_last = take< size< list_t > - i, list_t > |
Return a seqan3::type_list of the types the input type list, except the last n . More... | |
template<ptrdiff_t i, typename list_t > | |
using | seqan3::list_traits::split_after = decltype(detail::split_after< i >(list_t{})) |
Split a seqan3::type_list into two parts returned as a pair of seqan3::type_list. More... | |
template<template< typename > typename trait_t, typename list_t > | |
using | seqan3::list_traits::transform = decltype(detail::transform< trait_t >(list_t{})) |
Apply a transformation trait to every type in the list and return a seqan3::type_list of the results. More... | |
template<typename replace_t , std::ptrdiff_t i, typename list_t > | |
using | seqan3::list_traits::replace_at = decltype(detail::replace_at< replace_t, i >(list_t{})) |
Replace the type at the given index with the given type. More... | |
Type list traits (return a value) | |
template<typename ... pack_t> | |
constexpr size_t | seqan3::list_traits::size< type_list< pack_t... > > = sizeof...(pack_t) |
The size of a type list. More... | |
template<typename query_t , typename ... pack_t> | |
constexpr ptrdiff_t | seqan3::list_traits::count< query_t, type_list< pack_t... > > |
Count the occurrences of a type in a type list. More... | |
template<typename query_t , typename ... pack_t> | |
constexpr ptrdiff_t | seqan3::list_traits::find< query_t, type_list< pack_t... > > |
Get the index of the first occurrence of a type in a type list. More... | |
template<template< typename > typename pred_t, typename ... pack_t> | |
constexpr ptrdiff_t | seqan3::list_traits::find_if< pred_t, type_list< pack_t... > > |
Get the index of the first type in a type list that satisfies the given predicate. More... | |
template<typename query_t , typename list_t > | |
constexpr bool | seqan3::list_traits::contains = (find<query_t, list_t> != -1) |
Whether a type occurs in a type list or not. More... | |
Provides seqan3::type_list and metaprogramming utilities for working on type lists.
All traits on type lists are defined in the header <seqan3/utility/type_list/traits.hpp>
.
using seqan3::list_traits::at = typedef typename decltype(detail::at<idx>(list_t{}))::type |
Return the type at given index from the type list.
idx | The index; must be smaller than the size of the type list. |
list_t | The type_list. |
Negative indexes are supported (e.g. at<-1, type_list<int, double, bool &>>
is bool &
).
using seqan3::list_traits::back = typedef typename decltype(detail::back(list_t{}))::type |
Return the last type from the type list.
list_t | The type list. |
Notably faster than seqan3::pack_traits::at<size<pack...> - 1, pack...>
(no recursive template instantiations).
using seqan3::list_traits::concat = typedef decltype(detail::concat(lists_t{}...)) |
Join two seqan3::type_list s into one.
list1_t | The first (input) type list. |
list2_t | The second (input) type list. |
Complexity is independent of the number of types in each list.
using seqan3::list_traits::drop = typedef typename decltype(detail::split_after<i>(list_t{}))::second_type |
Return a seqan3::type_list of the types in the input type list, except the first n
.
i | The amount to drop; must be >= 0 and <= the size of the input type list. |
list_t | The (input) type list. |
using seqan3::list_traits::drop_front = typedef decltype(detail::drop_front(list_t{})) |
Return a seqan3::type_list of all the types in the type list, except the first.
list_t | The (input) type list. |
using seqan3::list_traits::drop_last = typedef take<size<list_t> - i, list_t> |
Return a seqan3::type_list of the types the input type list, except the last n
.
i | The amount to drop; must be >= 0 and <= the size of the input type list. |
list_t | The (input) type list. |
using seqan3::list_traits::front = typedef typename decltype(detail::front(list_t{}))::type |
Return the first type from the type list.
list_t | The type list. |
using seqan3::list_traits::replace_at = typedef decltype(detail::replace_at<replace_t, i>(list_t{})) |
Replace the type at the given index with the given type.
replace_t | The type to replace the old type with. |
i | The index of the type to be replaced. |
list_t | The (input) type list. |
using seqan3::list_traits::split_after = typedef decltype(detail::split_after<i>(list_t{})) |
Split a seqan3::type_list into two parts returned as a pair of seqan3::type_list.
i | The number of elements after which to split; must be >= 0 and <= the size of the input type list. |
list_t | The (input) type list. |
using seqan3::list_traits::take = typedef typename decltype(detail::split_after<i>(list_t{}))::first_type |
Return a seqan3::type_list of the first n
types in the input type list.
i | The target size; must be >= 0 and <= the size of the input type list. |
list_t | The (input) type list. |
using seqan3::list_traits::take_last = typedef drop<size<list_t> - i, list_t> |
Return a seqan3::type_list of the last n
types in the input type list.
i | The target size; must be >= 0 and <= the size of the input type list. |
list_t | The (input) type list. |
using seqan3::list_traits::transform = typedef decltype(detail::transform<trait_t>(list_t{})) |
Apply a transformation trait to every type in the list and return a seqan3::type_list of the results.
trait_t | The trait to transform, must be an alias template, e.g. a transformation trait shortcut. |
list_t | The (input) type list. |
The transformation trait given as first argument must be an alias template, e.g. std::type_identity_t, not std::type_identity. The alias must take exactly one argument and be defined for all types in the input list.
|
constexpr |
Tests whether a given predicate evaluates to true
for each type in a seqan3::type_list.
list_t | A type list; must model seqan3::detail::template_specialisation_of a seqan3::type_list |
unary_predicate_t | The function type, like function pointers, functors and lambdas; must model std::predicate expanded on each argument type wrapped in std::type_identity. |
[in] | fn | The predicate called for every type in the seqan3::type_list. |
true
if the predicate returns true
for each type in the type list, false
otherwise.This function operates on types instead of values. The following steps are performed to call the passed predicate on the types contained in the type list:
Note that wrapping the types in std::type_identity is a technical trick to make a type representable as a value. Instantiating a type might not work because they might not be std::default_initializable. In addition it is possible, to invoke the predicate on incomplete types.
Linear in the number of types in the seqan3::type_list.
[Compile-time complexity: Linear number of template instantiations.]
auto seqan3::list_traits::detail::concat | ( | type_list< pack1_t... > | , |
type_list< pack2_t... > | , | ||
more_lists_t ... | |||
) |
Implementation for seqan3::list_traits::concat [overload for more than two lists].
pack1_t | Types in the first type list. |
pack2_t | Types in the second type list. |
more_lists_t | The remaining type lists. |
pack_traits::drop_front< pack_t... > seqan3::list_traits::detail::drop_front | ( | type_list< pack_t... > | ) |
Implementation for seqan3::list_traits::drop_front.
pack_t | Types in the type list. |
|
constexpr |
Applies a function element wise to all types of a type list.
list_t | A type list; must model seqan3::detail::template_specialisation_of a seqan3::type_list. |
unary_function_t | The function type, like function pointers, functors and lambdas; must model std::invocable on each type of the type list wrapped in std::type_identity. |
[in] | fn | The function to call on every type contained in the list. |
This function operates on types instead of values. The following steps are performed to call the passed unary function on the types contained in the type list:
Note that wrapping the types in std::type_identity is a technical trick to make a type representable as a value. Instantiating a type might not work because they might not be std::default_initializable. In addition, it is possible to invoke the unary function on incomplete types.
Linear in the number of types in the seqan3::type_list.
[Compile-time complexity: Linear number of template instantiations.]
pack_traits::replace_at< replace_t, idx, pack_t... > seqan3::list_traits::detail::replace_at | ( | type_list< pack_t... > | ) |
Implementation for seqan3::list_traits::replace_at.
replace_t | The type replacing the old one. |
idx | The index of the type to replace. |
pack_t | Types in the type list to be modified. |
pack_traits::split_after< idx, pack1_t... > seqan3::list_traits::detail::split_after | ( | type_list< pack1_t... > | ) |
Implementation for seqan3::list_traits::split_after.
idx | The index after which to split. |
pack_t | Types in the type list to split |
std::type_identity< seqan3::pack_traits::at< idx, pack_t... > > seqan3::list_traits::detail::at(type_list< pack_t... >) | ( | type_list< pack_t... > | ) |
Implementation for seqan3::list_traits::at.
idx | The index. |
pack_t | Types in the type list. |
std::type_identity< seqan3::pack_traits::back< pack_t... > > seqan3::list_traits::detail::back(type_list< pack_t... >) | ( | type_list< pack_t... > | ) |
Implementation for seqan3::list_traits::back.
pack_t | Types in the type list. |
type_list< pack1_t..., pack2_t... > seqan3::list_traits::detail::concat(type_list< pack1_t... >, type_list< pack2_t... >) | ( | type_list< pack1_t... > | , |
type_list< pack2_t... > | |||
) |
Implementation for seqan3::list_traits::concat.
pack1_t | Types in the first type list. |
pack2_t | Types in the second type list. |
|
inlineconstexpr |
Whether a type occurs in a type list or not.
query_t | The type you are searching for. |
pack_t | The type pack. |
true
or false
.i
, where i
is the index of the first occurrence
|
inlineconstexpr |
Count the occurrences of a type in a type list.
query_t | The type you are searching for. |
pack_t | The type pack. |
query_t
in pack_t
.
|
inlineconstexpr |
Get the index of the first occurrence of a type in a type list.
query_t | The type you are searching for. |
pack_t | The type pack. |
query_t
in pack_t
or -1
if it is not contained.i
, where i
is the return value
|
inlineconstexpr |
Get the index of the first type in a type list that satisfies the given predicate.
pred_t | The predicate that is being evaluated (a class template). |
pack_t | The type pack. |
-1
if no types match.Note that the predicate must be given as a type template (variable templates cannot be passed as template arguments unfortunately). This means e.g. find_if<std::is_integral, float, double, int, float>
(not std::is_integral_v
!).
i
, where i
is the return valueOther operations: O(n), possibly == i
, where i
is the return value
Only the predicate is instantiated.
std::type_identity< seqan3::pack_traits::front< pack_t... > > seqan3::list_traits::detail::front(type_list< pack_t... >) | ( | type_list< pack_t... > | ) |
Implementation for seqan3::list_traits::front.
pack_t | Types in the type list. |
|
inlineconstexpr |
The size of a type list.
pack_t | The type pack. |
sizeof...(pack_t)
pack_traits::transform< trait_t, pack_t... > seqan3::list_traits::detail::transform(type_list< pack_t... >) | ( | type_list< pack_t... > | ) |
Implementation for seqan3::list_traits::transform.
trait_t | The trait to transform, must be an alias template, e.g. a transformation trait shortcut. |
pack_t | Types in the type list. |