SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
type_list_algorithm.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <concepts>
13#include <type_traits>
14#include <utility>
15
18
19namespace seqan3::detail
20{
21
23template <typename type_list_t>
24struct type_list_expander;
26
47template <template <typename...> typename type_list_t, typename... args_t>
48struct type_list_expander<type_list_t<args_t...>>
49{
60 template <typename fn_t>
61 requires std::invocable<fn_t, std::type_identity<args_t>...>
66};
67
68//-----------------------------------------------------------------------------
69// all_of
70//-----------------------------------------------------------------------------
71
106template <typename type_list_t, typename unary_predicate_t>
107[[nodiscard]] constexpr bool all_of(unary_predicate_t && fn)
109{
110 return type_list_expander<type_list_t>::invoke_on_type_identities(
111 [&](auto &&... type_identities)
112 {
113 return all_of(fn, std::forward<decltype(type_identities)>(type_identities)...);
114 });
115}
116
117//-----------------------------------------------------------------------------
118// for_each
119//-----------------------------------------------------------------------------
120
155template <typename type_list_t, typename unary_function_t>
157constexpr void for_each(unary_function_t && fn)
158{
159 type_list_expander<type_list_t>::invoke_on_type_identities(
160 [&](auto &&... type_identities)
161 {
162 for_each(fn, std::forward<decltype(type_identities)>(type_identities)...);
163 });
164}
165
166} // namespace seqan3::detail
T forward(T... args)
constexpr bool all_of(unary_predicate_t &&fn)
Tests whether a given predicate evaluates to true for each type in a seqan3::type_list.
Definition type_list_algorithm.hpp:107
constexpr void for_each(unary_function_t &&fn)
Applies a function element wise to all types of a type list.
Definition type_list_algorithm.hpp:157
Provides concept seqan3::template_specialisation_of<mytype, [...]> for checking the type specialisati...
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
static constexpr std::invoke_result_t< fn_t, std::type_identity< args_t >... > invoke_on_type_identities(fn_t &&fn)
Invokes the actual function by passing the types as instances of std::type_identity to the target fun...
Definition type_list_algorithm.hpp:62
Provides seqan3::type_list.
Provides algorithms for meta programming, parameter packs and seqan3::type_list.
Hide me