Provides seqan3::type_list and metaprogramming utilities for working on type lists.
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].
|
|
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<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..
|
|
Provides seqan3::type_list and metaprogramming utilities for working on type lists.
- See also
- Utility
All traits on type lists are defined in the header <seqan3/utility/type_list/traits.hpp>
.
◆ at
Return the type at given index from the type list.
- Template Parameters
-
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 &
).
(Compile-time) Complexity
- Number of template instantiations: O(n)
- Other operations: O(n)
int main()
{
static_assert(std::same_as<float, seqan3::list_traits::at<1, list_t>>);
}
A "pretty printer" for most SeqAn data structures and related types.
Definition debug_stream_type.hpp:79
typename decltype(detail::at< idx >(list_t{}))::type at
Return the type at given index from the type list.
Definition type_list/traits.hpp:276
Provides traits for seqan3::type_list.
◆ back
Return the last type from the type list.
- Template Parameters
-
(Compile-time) Complexity
- Number of template instantiations: O(n) (possibly O(1))
- Other operations: O(1)
Notably faster than seqan3::pack_traits::at<size<pack...> - 1, pack...>
(no recursive template instantiations).
int main()
{
static_assert(std::same_as<float, seqan3::list_traits::back<list_t>>);
}
◆ concat
template<typename... lists_t>
Join two seqan3::type_list s into one.
- Template Parameters
-
list1_t | The first (input) type list. |
list2_t | The second (input) type list. |
(Compile-time) Complexity
- Number of template instantiations: O(n) in the number of type lists
- Other operations: O(n) in the number of type lists
Complexity is independent of the number of types in each list.
int main()
{
static_assert(std::same_as<seqan3::list_traits::concat<list_t, list_t2, list_t3>,
}
◆ drop
Return a seqan3::type_list of the types in the input type list, except the first n
.
- Template Parameters
-
i | The amount to drop; must be >= 0 and <= the size of the input type list. |
list_t | The (input) type list. |
(Compile-time) Complexity
- Number of template instantiations: O(n)
- Other operations: O(n)
int main()
{
}
typename decltype(detail::split_after< i >(list_t{}))::second_type drop
Return a seqan3::type_list of the types in the input type list, except the first n.
Definition type_list/traits.hpp:392
◆ drop_front
Return a seqan3::type_list of all the types in the type list, except the first.
- Template Parameters
-
list_t | The (input) type list. |
(Compile-time) Complexity
- Number of template instantiations: O(1)
- Other operations: O(1)
int main()
{
}
decltype(detail::drop_front(list_t{})) drop_front
Return a seqan3::type_list of all the types in the type list, except the first.
Definition type_list/traits.hpp:356
◆ drop_last
Return a seqan3::type_list of the types the input type list, except the last n
.
- Template Parameters
-
i | The amount to drop; must be >= 0 and <= the size of the input type list. |
list_t | The (input) type list. |
(Compile-time) Complexity
- Number of template instantiations: O(n)
- Other operations: O(n)
◆ front
Return the first type from the type list.
- Template Parameters
-
(Compile-time) Complexity
- Number of template instantiations: O(1)
- Other operations: O(1)
int main()
{
static_assert(std::same_as<int, seqan3::list_traits::front<list_t>>);
}
◆ repeat
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.
◆ replace_at
Replace the type at the given index with the given type.
- Template Parameters
-
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. |
(Compile-time) Complexity
- Number of template instantiations: O(n)
- Other operations: O(n)
int main()
{
static_assert(
}
decltype(detail::replace_at< replace_t, i >(list_t{})) replace_at
Replace the type at the given index with the given type.
Definition type_list/traits.hpp:486
◆ split_after
Split a seqan3::type_list into two parts returned as a pair of seqan3::type_list.
- Template Parameters
-
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. |
(Compile-time) Complexity
- Number of template instantiations: O(n)
- Other operations: O(n)
◆ take
Return a seqan3::type_list of the first n
types in the input type list.
- Template Parameters
-
i | The target size; must be >= 0 and <= the size of the input type list. |
list_t | The (input) type list. |
(Compile-time) Complexity
- Number of template instantiations: O(n)
- Other operations: O(n)
int main()
{
}
typename decltype(detail::split_after< i >(list_t{}))::first_type take
Return a seqan3::type_list of the first n types in the input type list.
Definition type_list/traits.hpp:374
◆ take_last
Return a seqan3::type_list of the last n
types in the input type list.
- Template Parameters
-
i | The target size; must be >= 0 and <= the size of the input type list. |
list_t | The (input) type list. |
(Compile-time) Complexity
- Number of template instantiations: O(n)
- Other operations: O(n)
◆ transform
Apply a transformation trait to every type in the list and return a seqan3::type_list of the results.
- Template Parameters
-
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.
(Compile-time) Complexity
- Number of template instantiations: O(n)
- Other operations: O(n)
int main()
{
static_assert(std::same_as<seqan3::list_traits::transform<std::ranges::range_reference_t, list_t>,
}
Provides various transformation traits used by the range module.
◆ concat()
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 Parameters
-
pack1_t | Types in the first type list. |
pack2_t | Types in the second type list. |
more_lists_t | The remaining type lists. |
◆ drop_front()
template<typename... pack_t>
◆ repeat()
auto seqan3::list_traits::detail::repeat |
( |
| ) |
|
◆ replace_at()
Implementation for seqan3::list_traits::replace_at.
- Template Parameters
-
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. |
◆ split_after()
template<ptrdiff_t idx, typename... pack1_t>
◆ at
template<ptrdiff_t idx, typename... pack_t>
◆ back
template<typename... pack_t>
◆ concat
template<typename... pack1_t, typename... pack2_t>
Implementation for seqan3::list_traits::concat.
- Template Parameters
-
pack1_t | Types in the first type list. |
pack2_t | Types in the second type list. |
◆ contains
Whether a type occurs in a type list or not.
- Template Parameters
-
query_t | The type you are searching for. |
pack_t | The type pack. |
- Returns
true
or false
.
(Compile-time) Complexity
- Number of template instantiations: O(1)
- Other operations: O(n), possibly ==
i
, where i
is the index of the first occurrence
int main()
{
static_assert(seqan3::pack_traits::find<double, int, float, bool> == -1);
static_assert(seqan3::pack_traits::find<bool, int, float, bool> == 2);
}
Provides various traits for template packs.
int main()
{
static_assert(seqan3::list_traits::contains<double, list_t> == false);
static_assert(seqan3::list_traits::contains<float, list_t> == true);
}
◆ count< query_t, type_list< pack_t... > >
Count the occurrences of a type in a type list.
- Template Parameters
-
query_t | The type you are searching for. |
pack_t | The type pack. |
- Returns
- The number of occurrences of the
query_t
in pack_t
.
(Compile-time) Complexity
- Number of template instantiations: O(1)
- Other operations: O(n)
int main()
{
static_assert(seqan3::pack_traits::count<int, int, float, bool, int> == 2);
}
int main()
{
static_assert(seqan3::list_traits::count<int, list_t> == 2);
}
◆ find< query_t, type_list< pack_t... > >
Initial value:=
constexpr ptrdiff_t find()
Implementation for seqan3::pack_traits::find.
Definition type_pack/traits.hpp:31
Get the index of the first occurrence of a type in a type list.
- Template Parameters
-
query_t | The type you are searching for. |
pack_t | The type pack. |
- Returns
- The position of the first occurrence of
query_t
in pack_t
or -1
if it is not contained.
(Compile-time) Complexity
- Number of template instantiations: O(1)
- Other operations: O(n), possibly ==
i
, where i
is the return value
int main()
{
static_assert(seqan3::pack_traits::find<double, int, float, bool> == -1);
static_assert(seqan3::pack_traits::find<bool, int, float, bool> == 2);
}
int main()
{
static_assert(seqan3::list_traits::find<double, list_t> == -1);
static_assert(seqan3::list_traits::find<bool, list_t> == 2);
}
◆ find_if< pred_t, type_list< pack_t... > >
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);
}
◆ front
template<typename... pack_t>
◆ size< type_list< pack_t... > >
template<typename... pack_t>
The size of a type list.
- Template Parameters
-
- Returns
sizeof...(pack_t)
(Compile-time) Complexity
- Number of template instantiations: O(1)
- Other operations: O(1)
int main()
{
static_assert(seqan3::pack_traits::size<int, float, bool, int> == 4);
}
int main()
{
static_assert(seqan3::list_traits::size<list_t> == 4);
}
◆ transform
Implementation for seqan3::list_traits::transform.
- Template Parameters
-
trait_t | The trait to transform, must be an alias template, e.g. a transformation trait shortcut. |
pack_t | Types in the type list. |