SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
Type List

Provides seqan3::type_list and metaprogramming utilities for working on type lists. More...

+ Collaboration diagram for 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 >
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.
 

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.
 
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.
 
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.
 
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.
 
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.
 

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.
 
template<typename list_t >
using seqan3::list_traits::front = typename decltype(detail::front(list_t{}))::type
 Return the first type from the type list.
 
template<typename list_t >
using seqan3::list_traits::back = typename decltype(detail::back(list_t{}))::type
 Return the last type from the type list.
 

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.
 
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..
 

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.
 
template<typename query_t , typename... pack_t>
constexpr ptrdiff_t seqan3::list_traits::count< query_t, type_list< pack_t... > > = seqan3::pack_traits::count<query_t, pack_t...>
 Count the occurrences of a type in a type list.
 
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.
 
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.
 
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.
 

Detailed Description

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>.

Typedef Documentation

◆ at

template<ptrdiff_t idx, typename list_t >
using seqan3::list_traits::at = typedef typename decltype(detail::at<idx>(list_t{}))::type

Return the type at given index from the type list.

Template Parameters
idxThe index; must be smaller than the size of the type list.
list_tThe 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)
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// Look at the 2nd element.
static_assert(std::same_as<float, seqan3::list_traits::at<1, list_t>>);
// Look at the last element.
static_assert(std::same_as<double, seqan3::list_traits::at<-1, list_t>>);
}
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
Type that contains multiple types.
Definition type_list.hpp:26
Provides traits for seqan3::type_list.

◆ back

template<typename list_t >
using seqan3::list_traits::back = typedef typename decltype(detail::back(list_t{}))::type

Return the last type from the type list.

Template Parameters
list_tThe type list.

(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).

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// Access the last value (float) with seqan3::list_traits::back
static_assert(std::same_as<float, seqan3::list_traits::back<list_t>>);
}

◆ concat

template<typename... lists_t>
using seqan3::list_traits::concat = typedef decltype(detail::concat(lists_t{}...))

Join two seqan3::type_list s into one.

Template Parameters
list1_tThe first (input) type list.
list2_tThe 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.

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
using list_t3 = seqan3::type_list<int, int>;
static_assert(std::same_as<seqan3::list_traits::concat<list_t, list_t2, list_t3>,
}

◆ drop

template<ptrdiff_t i, typename list_t >
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.

Template Parameters
iThe amount to drop; must be >= 0 and <= the size of the input type list.
list_tThe (input) type list.

(Compile-time) Complexity

  • Number of template instantiations: O(n)
  • Other operations: O(n)
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// Drop the first two types in list_t.
static_assert(std::same_as<seqan3::type_list<bool, int>, seqan3::list_traits::drop<2, list_t>>);
}
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

template<typename list_t >
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.

Template Parameters
list_tThe (input) type list.

(Compile-time) Complexity

  • Number of template instantiations: O(1)
  • Other operations: O(1)
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
static_assert(std::same_as<seqan3::type_list<float, bool, int>, seqan3::list_traits::drop_front<list_t>>);
}
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

template<ptrdiff_t i, typename list_t >
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.

Template Parameters
iThe amount to drop; must be >= 0 and <= the size of the input type list.
list_tThe (input) type list.

(Compile-time) Complexity

  • Number of template instantiations: O(n)
  • Other operations: O(n)
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// Drop the last two types in list_t.
static_assert(std::same_as<seqan3::type_list<int, float>, seqan3::list_traits::drop_last<2, list_t>>);
}
take< size< list_t > - i, list_t > drop_last
Return a seqan3::type_list of the types the input type list, except the last n.
Definition type_list/traits.hpp:428

◆ front

template<typename list_t >
using seqan3::list_traits::front = typedef typename decltype(detail::front(list_t{}))::type

Return the first type from the type list.

Template Parameters
list_tThe type list.

(Compile-time) Complexity

  • Number of template instantiations: O(1)
  • Other operations: O(1)
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
static_assert(std::same_as<int, seqan3::list_traits::front<list_t>>); // Check if the first value is int.
}

◆ repeat

template<size_t count, typename t >
using seqan3::list_traits::repeat = typedef decltype(detail::repeat<count, t>())

Create a type list with the given type repeated count times..

Template Parameters
countThe number of repititions.
tThe 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

template<typename replace_t , std::ptrdiff_t i, typename list_t >
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.

Template Parameters
replace_tThe type to replace the old type with.
iThe index of the type to be replaced.
list_tThe (input) type list.

(Compile-time) Complexity

  • Number of template instantiations: O(n)
  • Other operations: O(n)
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// Replace the second element with int.
static_assert(
std::same_as<seqan3::type_list<int, int, bool, double>, seqan3::list_traits::replace_at<int, 1, list_t>>);
}
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

template<ptrdiff_t i, typename list_t >
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.

Template Parameters
iThe number of elements after which to split; must be >= 0 and <= the size of the input type list.
list_tThe (input) type list.

(Compile-time) Complexity

  • Number of template instantiations: O(n)
  • Other operations: O(n)
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// Drop the last two types in list_t.
static_assert(std::same_as<seqan3::type_list<int, float>, seqan3::list_traits::drop_last<2, list_t>>);
}

◆ take

template<ptrdiff_t i, typename list_t >
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.

Template Parameters
iThe target size; must be >= 0 and <= the size of the input type list.
list_tThe (input) type list.

(Compile-time) Complexity

  • Number of template instantiations: O(n)
  • Other operations: O(n)
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// Take the first two types in list_t.
static_assert(std::same_as<seqan3::type_list<int, float>, seqan3::list_traits::take<2, list_t>>);
}
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

template<ptrdiff_t i, typename list_t >
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.

Template Parameters
iThe target size; must be >= 0 and <= the size of the input type list.
list_tThe (input) type list.

(Compile-time) Complexity

  • Number of template instantiations: O(n)
  • Other operations: O(n)
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// Take the last two types in list_t.
static_assert(std::same_as<seqan3::type_list<bool, int>, seqan3::list_traits::take_last<2, list_t>>);
}
drop< size< list_t > - i, list_t > take_last
Return a seqan3::type_list of the last n types in the input type list.
Definition type_list/traits.hpp:410

◆ transform

template<template< typename > typename trait_t, typename list_t >
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.

Template Parameters
trait_tThe trait to transform, must be an alias template, e.g. a transformation trait shortcut.
list_tThe (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)
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <list>
#include <vector>
int main()
{
// Transform the types into reference types.
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.

Function Documentation

◆ all_of()

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)
constexpr

Tests whether a given predicate evaluates to true for each type in a seqan3::type_list.

Template Parameters
list_tA type list; must model seqan3::detail::template_specialisation_of a seqan3::type_list
unary_predicate_tThe function type, like function pointers, functors and lambdas; must model std::predicate expanded on each argument type wrapped in std::type_identity.
Parameters
[in]fnThe predicate called for every type in the seqan3::type_list.
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

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <type_traits>
namespace incomplete
{
struct type;
} // namespace incomplete
// With c++20 you could also write it like this
// auto fn = []<typename type>(std::type_identity<type>)
// {
// ...
// };
auto fn = [](auto id)
{
// id is of type std::type_identity<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)); // evaluates to true
static_assert(!seqan3::detail::all_of<seqan3::type_list<int, float, bool, incomplete::type>>(fn)); // evaluates to false
@ 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.]

◆ 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_tTypes in the first type list.
pack2_tTypes in the second type list.
more_lists_tThe remaining type lists.

◆ drop_front()

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 Parameters
pack_tTypes in the type list.

◆ for_each()

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)
constexpr

Applies a function element wise to all types of a type list.

Template Parameters
list_tA type list; must model seqan3::detail::template_specialisation_of a seqan3::type_list.
unary_function_tThe function type, like function pointers, functors and lambdas; must model std::invocable on each type of the type list wrapped in std::type_identity.
Parameters
[in]fnThe 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

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <string>
namespace incomplete
{
struct type;
} // namespace incomplete
int main()
{
// With c++20 you could also write it like this
// auto fn = []<typename type>(std::type_identity<type>)
// {
// ...
// };
auto fn = [](auto id)
{
// id is of type std::type_identity<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>)
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::debug_stream << "incomplete::type";
};
// prints each type name, i.e. "int, float, bool, incomplete::type, \n"
seqan3::detail::for_each<types>(fn);
// is the same as explicitly writing
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

◆ repeat()

template<size_t count, typename t >
auto seqan3::list_traits::detail::repeat ( )

Implementation for seqan3::list_traits::repeat.

Template Parameters
countThe number of repititions.
tThe type to repeat

◆ replace_at()

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 Parameters
replace_tThe type replacing the old one.
idxThe index of the type to replace.
pack_tTypes in the type list to be modified.

◆ split_after()

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 Parameters
idxThe index after which to split.
pack_tTypes in the type list to split

Variable Documentation

◆ at

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... >) ( type_list< pack_t... >  )

Implementation for seqan3::list_traits::at.

Template Parameters
idxThe index.
pack_tTypes in the type list.

◆ back

template<typename... pack_t>
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.

Template Parameters
pack_tTypes in the type list.

◆ concat

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... >) ( type_list< pack1_t... >  ,
type_list< pack2_t... >   
)

Implementation for seqan3::list_traits::concat.

Template Parameters
pack1_tTypes in the first type list.
pack2_tTypes in the second type list.

◆ contains

template<typename query_t , typename list_t >
constexpr bool seqan3::list_traits::contains = (find<query_t, list_t> != -1)
inlineconstexpr

Whether a type occurs in a type list or not.

Template Parameters
query_tThe type you are searching for.
pack_tThe 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
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// Double is not in the pack so find returns -1. However, bool is in the pack so find will return 2.
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.
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
static_assert(seqan3::list_traits::contains<double, list_t> == false); // Is type double in type_list list_t?
static_assert(seqan3::list_traits::contains<float, list_t> == true); // Is type float in type_list list_t?
}

◆ count< query_t, type_list< pack_t... > >

template<typename query_t , typename... pack_t>
constexpr ptrdiff_t seqan3::list_traits::count< query_t, type_list< pack_t... > > = seqan3::pack_traits::count<query_t, pack_t...>
inlineconstexpr

Count the occurrences of a type in a type list.

Template Parameters
query_tThe type you are searching for.
pack_tThe 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)
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// Count the number of type int in the pack.
static_assert(seqan3::pack_traits::count<int, int, float, bool, int> == 2);
}
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// Count the number of type int in list_t.
static_assert(seqan3::list_traits::count<int, list_t> == 2);
}

◆ find< query_t, type_list< pack_t... > >

template<typename query_t , typename... pack_t>
constexpr ptrdiff_t seqan3::list_traits::find< query_t, type_list< pack_t... > >
inlineconstexpr
Initial value:
=
seqan3::pack_traits::detail::find<query_t, pack_t...>()
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_tThe type you are searching for.
pack_tThe 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
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// Double is not in the pack so find returns -1. However, bool is in the pack so find will return 2.
static_assert(seqan3::pack_traits::find<double, int, float, bool> == -1);
static_assert(seqan3::pack_traits::find<bool, int, float, bool> == 2);
}
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// Double is not in list_t so find returns -1. However, bool is in the type list so find will return 2.
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... > >

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_tThe predicate that is being evaluated (a class template).
pack_tThe 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.

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// None of the types in t is a pointer so find_if returns -1. However, int and bool are both integral,
// so find_if returns 0 for the first occurrence.
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);
}
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// None of the types in list_t is a pointer so find_if returns -1. However, int and bool are both integral,
// so find_if returns 0 for the first occurrence.
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>
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.

Template Parameters
pack_tTypes in the type list.

◆ size< type_list< pack_t... > >

template<typename... pack_t>
constexpr size_t seqan3::list_traits::size< type_list< pack_t... > > = sizeof...(pack_t)
inlineconstexpr

The size of a type list.

Template Parameters
pack_tThe type pack.
Returns
sizeof...(pack_t)

(Compile-time) Complexity

  • Number of template instantiations: O(1)
  • Other operations: O(1)
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
// Get the size of the pack.
static_assert(seqan3::pack_traits::size<int, float, bool, int> == 4);
}
// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
static_assert(seqan3::list_traits::size<list_t> == 4);
}

◆ transform

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... >) ( type_list< pack_t... >  )

Implementation for seqan3::list_traits::transform.

Template Parameters
trait_tThe trait to transform, must be an alias template, e.g. a transformation trait shortcut.
pack_tTypes in the type list.
Hide me