BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
function.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2022 deCODE Genetics
3// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
4// Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
5// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
6// shipped with this file and also available at: https://github.com/biocpp/biocpp-core/blob/main/LICENSE.md
7// -----------------------------------------------------------------------------------------------------
8
14#pragma once
15
16#include <concepts>
17#include <type_traits>
18#include <utility>
19
21
22namespace bio::meta::detail
23{
24
25//-----------------------------------------------------------------------------
26// all_of
27//-----------------------------------------------------------------------------
28
63template <typename type_list_t, typename unary_predicate_t>
64[[nodiscard]] constexpr bool all_of(unary_predicate_t && fn)
65 requires template_specialisation_of<type_list_t, type_list>
66{
67 return [&]<typename... ts>(type_list<ts...>) { return (fn(std::type_identity<ts>{}) && ...); }(type_list_t{});
68}
69
70//-----------------------------------------------------------------------------
71// for_each
72//-----------------------------------------------------------------------------
73
108template <typename type_list_t, typename unary_function_t>
109 requires template_specialisation_of<type_list_t, bio::meta::type_list>
110constexpr void for_each(unary_function_t && fn)
111{
112 return [&]<typename... ts>(type_list<ts...>) { (fn(std::type_identity<ts>{}), ...); }(type_list_t{});
113}
114
115} // namespace bio::meta::detail
T all_of(T... args)
T for_each(T... args)
Provides bio::meta::type_list.