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>...>
62 static constexpr std::invoke_result_t<fn_t, std::type_identity<args_t>...> invoke_on_type_identities(fn_t && fn)
63 {
64 return fn(std::type_identity<args_t>{}...);
65 }
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)
108 requires template_specialisation_of<type_list_t, seqan3::type_list>
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>
156 requires template_specialisation_of<type_list_t, seqan3::type_list>
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 all_of(T... args)
T for_each(T... args)
T forward(T... args)
Provides seqan3::type_list.
Provides algorithms for meta programming, parameter packs and seqan3::type_list.
Hide me