RESTinio
Toggle main menu visibility
Loading...
Searching...
No Matches
restinio
utils
tuple_algorithms.hpp
Go to the documentation of this file.
1
/*
2
* RESTinio
3
*/
4
5
/*!
6
* @file
7
* @brief Various meta-functions for operating the content of a tuple.
8
*
9
* @since v.0.6.1
10
*/
11
12
#
pragma
once
13
14
#
include
<
restinio
/
compiler_features
.
hpp
>
15
16
#
include
<
utility
>
17
#
include
<
tuple
>
18
19
namespace
restinio
20
{
21
22
namespace
utils
23
{
24
25
namespace
tuple_algorithms
26
{
27
28
namespace
impl
29
{
30
31
template
<
typename
T >
32
using
index_sequence_for_tuple
=
33
std::make_index_sequence< std::tuple_size<T>::value >;
34
35
template
<
typename
Predicate,
typename
Tuple, std::size_t... I >
36
[[nodiscard]]
37
bool
38
perform_all_of
(
39
Predicate && p,
40
Tuple && t,
41
std::index_sequence<I...> )
42
{
43
// Use fold expression after switching to C++17.
44
return
(p( std::get<I>(std::forward<Tuple>(t)) ) && ...);
45
}
46
47
template
<
typename
Predicate,
typename
Tuple, std::size_t... I >
48
[[nodiscard]]
49
bool
50
perform_any_of
(
51
Predicate && p,
52
Tuple && t,
53
std::index_sequence<I...> )
54
{
55
// Use fold expression after switching to C++17.
56
return
(p( std::get<I>(std::forward<Tuple>(t)) ) || ...);
57
}
58
59
}
/* namespace impl */
60
61
//
62
// all_of
63
//
64
template
<
typename
Tuple,
typename
Predicate >
65
[[nodiscard]]
66
bool
67
all_of
( Tuple && tuple, Predicate && predicate )
68
{
69
return
impl
::perform_all_of(
70
std::forward<Predicate>(predicate),
71
std::forward<Tuple>(tuple),
72
typename
impl
::
index_sequence_for_tuple
<std::decay_t<Tuple>>{} );
73
}
74
75
//
76
// any_of
77
//
78
template
<
typename
Tuple,
typename
Predicate >
79
[[nodiscard]]
80
bool
81
any_of
( Tuple && tuple, Predicate && predicate )
82
{
83
return
impl
::perform_any_of(
84
std::forward<Predicate>(predicate),
85
std::forward<Tuple>(tuple),
86
typename
impl
::
index_sequence_for_tuple
<std::decay_t<Tuple>>{} );
87
}
88
89
}
/* namespace tuple_algorithms */
90
91
}
/* namespace utils */
92
93
}
/* namespace restinio */
restinio::utils::tuple_algorithms::impl
Definition
tuple_algorithms.hpp:29
restinio::utils::tuple_algorithms::impl::index_sequence_for_tuple
std::make_index_sequence< std::tuple_size< T >::value > index_sequence_for_tuple
Definition
tuple_algorithms.hpp:32
restinio::utils::tuple_algorithms::impl::perform_all_of
bool perform_all_of(Predicate &&p, Tuple &&t, std::index_sequence< I... >)
Definition
tuple_algorithms.hpp:38
restinio::utils::tuple_algorithms::impl::perform_any_of
bool perform_any_of(Predicate &&p, Tuple &&t, std::index_sequence< I... >)
Definition
tuple_algorithms.hpp:50
restinio::utils::tuple_algorithms
Definition
tuple_algorithms.hpp:26
restinio::utils::tuple_algorithms::all_of
bool all_of(Tuple &&tuple, Predicate &&predicate)
Definition
tuple_algorithms.hpp:67
restinio::utils::tuple_algorithms::any_of
bool any_of(Tuple &&tuple, Predicate &&predicate)
Definition
tuple_algorithms.hpp:81
restinio::utils
Definition
from_string_details.ipp:5
restinio
Definition
sendfile_operation_default.ipp:12
Generated by
1.17.0