|
template<typename type_list_t , typename unary_predicate_t >
requires template_specialisation_of<type_list_t, seqan3::type_list> |
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.
|
|
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].
|
|
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.
|
|
template<typename type_list_t , typename unary_function_t >
requires template_specialisation_of<type_list_t, seqan3::type_list> |
constexpr void | seqan3::detail::for_each (unary_function_t &&fn) |
| Applies a function element wise to all types of a type list.
|
|
template<size_t count, typename t > |
auto | seqan3::list_traits::detail::repeat () |
| Implementation for seqan3::list_traits::repeat.
|
|
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.
|
|
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.
|
|
|
template<typename... lists_t> |
using | seqan3::list_traits::concat = decltype(detail::concat(lists_t{}...)) |
| Join two seqan3::type_list s into one.
|
|
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.
|
|
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.
|
|
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 .
|
|
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.
|
|
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 .
|
|
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.
|
|
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.
|
|
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.
|
|
template<size_t count, typename t > |
using | seqan3::list_traits::repeat = decltype(detail::repeat< count, t >()) |
| Create a type list with the given type repeated count times..
|
|
template<size_t count, typename t >
Create a type list with the given type repeated count
times..
- Template Parameters
-
count | The number of repititions. |
t | The type to repeat |
(Compile-time) Complexity
- Number of template instantiations: O(n)
- Other operations: O(n)
However, with a constant of 0.2, e.g. repeat<10,int> results in 2-3 instantiations.
constexpr bool seqan3::detail::all_of |
( |
unary_predicate_t && |
fn | ) |
|
|
constexpr |
Tests whether a given predicate evaluates to true
for each type in a seqan3::type_list.
- Template Parameters
-
- Parameters
-
- Returns
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.
Example
namespace incomplete
{
struct type;
}
{
using id_t =
decltype(
id);
using type = typename id_t::type;
static_assert(std::is_same_v<id_t, std::type_identity<type>>, "id is of type std::type_identity<type>");
if constexpr (std::is_same_v<type, bool>)
return true;
else if constexpr (std::is_same_v<type, int>)
return true;
else if constexpr (std::is_same_v<type, float>)
return true;
else if constexpr (std::is_same_v<type, incomplete::type>)
return false;
};
static_assert(seqan3::detail::all_of<seqan3::type_list<int, float, bool>>(fn));
static_assert(!seqan3::detail::all_of<seqan3::type_list<int, float, bool, incomplete::type>>(fn));
@ id
The identifier, usually a string.
Provides seqan3::type_list.
Provides algorithms for meta programming, parameter packs and seqan3::type_list.
Complexity
Linear in the number of types in the seqan3::type_list.
[Compile-time complexity: Linear number of template instantiations.]
constexpr void seqan3::detail::for_each |
( |
unary_function_t && |
fn | ) |
|
|
constexpr |
Applies a function element wise to all types of a type list.
- Template Parameters
-
- Parameters
-
[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.
Example
namespace incomplete
{
struct type;
}
int main()
{
{
using id_t =
decltype(
id);
using type = typename id_t::type;
static_assert(std::is_same_v<id_t, std::type_identity<type>>, "id is of type std::type_identity<type>");
if constexpr (std::is_same_v<type, bool>)
else if constexpr (std::is_same_v<type, int>)
else if constexpr (std::is_same_v<type, float>)
else if constexpr (std::is_same_v<type, incomplete::type>)
};
seqan3::detail::for_each<types>(fn);
return 0;
}
Provides seqan3::debug_stream and related types.
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition debug_stream.hpp:37
Complexity
Linear in the number of types in the seqan3::type_list.
[Compile-time complexity: Linear number of template instantiations.]
- See also
- seqan3::detail::for_each
template<template< typename > typename pred_t, typename... pack_t>
constexpr ptrdiff_t seqan3::list_traits::find_if< pred_t, type_list< pack_t... > > |
|
inlineconstexpr |
Initial value:=
constexpr ptrdiff_t find_if()
Implementation for seqan3::pack_traits::find_if.
Definition type_pack/traits.hpp:44
Get the index of the first type in a type list that satisfies the given predicate.
- Template Parameters
-
pred_t | The predicate that is being evaluated (a class template). |
pack_t | The type pack. |
- Returns
- The index or
-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
!).
(Compile-time) Complexity
- Number of template instantiations: O(n), possibly ==
i
, where i
is the return value
Other operations: O(n), possibly == i
, where i
is the return value
Only the predicate is instantiated.
int main()
{
static_assert(seqan3::pack_traits::find_if<std::is_pointer, int, float, double> == -1);
static_assert(seqan3::pack_traits::find_if<std::is_integral, int, float, double> == 0);
}
int main()
{
static_assert(seqan3::list_traits::find_if<std::is_pointer, list_t> == -1);
static_assert(seqan3::list_traits::find_if<std::is_integral, list_t> == 0);
}