RESTinio
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 
26 {
27 
28 namespace impl
29 {
30 
31 template< typename T >
34 
35 template< typename Predicate >
37 bool
39 {
40  return true;
41 }
42 
43 template< typename Predicate, typename T, typename... Vs >
45 bool
47 {
48  return p( std::forward<T>(current) ) &&
50 }
51 
52 template< typename Predicate, typename Tuple, std::size_t... I >
54 bool
56  Predicate && p,
57  Tuple && t,
58  std::index_sequence<I...> )
59 {
60  return all_of_impl(
62  std::get<I>(std::forward<Tuple>(t))... );
63 }
64 
65 template< typename Predicate >
67 bool
69 {
70  return false;
71 }
72 
73 template< typename Predicate, typename T, typename... Vs >
75 bool
77 {
78  return p( std::forward<T>(current) ) ||
80 }
81 
82 template< typename Predicate, typename Tuple, std::size_t... I >
84 bool
86  Predicate && p,
87  Tuple && t,
88  std::index_sequence<I...> )
89 {
90  return any_of_impl(
92  std::get<I>(std::forward<Tuple>(t))... );
93 }
94 
95 } /* namespace impl */
96 
97 //
98 // all_of
99 //
100 template< typename Tuple, typename Predicate >
102 bool
104 {
105  return impl::perform_all_of(
107  std::forward<Tuple>(tuple),
108  typename impl::index_sequence_for_tuple<std::decay_t<Tuple>>{} );
109 }
110 
111 //
112 // any_of
113 //
114 template< typename Tuple, typename Predicate >
116 bool
118 {
119  return impl::perform_any_of(
121  std::forward<Tuple>(tuple),
122  typename impl::index_sequence_for_tuple<std::decay_t<Tuple>>{} );
123 }
124 
125 } /* namespace tuple_algorithms */
126 
127 } /* namespace utils */
128 
129 } /* namespace restinio */
RESTINIO_NODISCARD bool any_of(Tuple &&tuple, Predicate &&predicate)
void normalize_to(string_view_t what, char *dest)
Perform normalization of URI value.
RESTINIO_NODISCARD bool perform_any_of(Predicate &&p, Tuple &&t, std::index_sequence< I... >)
std::enable_if< std::is_same< Parameter_Container, query_string_params_t >::value||std::is_same< Parameter_Container, router::route_params_t >::value, optional_t< Value_Type > >::type opt_value(const Parameter_Container &params, string_view_t key)
Gets the value of a parameter specified by key wrapped in optional_t<Value_Type> if parameter exists ...
Definition: value_or.hpp:64