SeqAn3 3.2.0
The Modern C++ library for sequence analysis.
type_list_algorithm.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6// -----------------------------------------------------------------------------------------------------
7
13#pragma once
14
15#include <concepts>
16#include <type_traits>
17#include <utility>
18
21
22namespace seqan3::detail
23{
24
26template <typename type_list_t>
27struct type_list_expander;
29
50template <template <typename...> typename type_list_t, typename... args_t>
51struct type_list_expander<type_list_t<args_t...>>
52{
63 template <typename fn_t>
64 requires std::invocable<fn_t, std::type_identity<args_t>...>
65 static constexpr std::invoke_result_t<fn_t, std::type_identity<args_t>...> invoke_on_type_identities(fn_t && fn)
66 {
67 return fn(std::type_identity<args_t>{}...);
68 }
69};
70
71//-----------------------------------------------------------------------------
72// all_of
73//-----------------------------------------------------------------------------
74
109template <typename type_list_t, typename unary_predicate_t>
110[[nodiscard]] constexpr bool all_of(unary_predicate_t && fn)
111 requires template_specialisation_of<type_list_t, seqan3::type_list>
112{
113 return type_list_expander<type_list_t>::invoke_on_type_identities(
114 [&](auto &&... type_identities)
115 {
116 return all_of(fn, std::forward<decltype(type_identities)>(type_identities)...);
117 });
118}
119
120//-----------------------------------------------------------------------------
121// for_each
122//-----------------------------------------------------------------------------
123
158template <typename type_list_t, typename unary_function_t>
159 requires template_specialisation_of<type_list_t, seqan3::type_list>
160constexpr void for_each(unary_function_t && fn)
161{
162 type_list_expander<type_list_t>::invoke_on_type_identities(
163 [&](auto &&... type_identities)
164 {
165 for_each(fn, std::forward<decltype(type_identities)>(type_identities)...);
166 });
167}
168
169} // 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.