33template<
typename Tuple>
34Tuple untuple(Tuple t) {
39T untuple(std::tuple<T> t) {
40 return std::get<0>(std::move(t));
43template<
typename Tuple,
typename Function,
size_t... I>
44void tuple_for_each_helper(Tuple&& t, Function&& f, std::index_sequence<I...>&&) {
45 auto ignore_me = { (f(std::get<I>(std::forward<Tuple>(t))), 1)... };
49template<
typename Tuple,
typename MapFunction,
size_t... I>
50auto tuple_map_helper(Tuple&& t, MapFunction&& f, std::index_sequence<I...>&&) {
51 return std::make_tuple(f(std::get<I>(std::forward<Tuple>(t)))...);
54template<
size_t I,
typename IndexSequence>
57template<
size_t I,
size_t... Is>
58struct prepend<I,
std::index_sequence<Is...>> {
59 using type = std::index_sequence<I, Is...>;
62template<
template<
typename>
class Filter,
typename Tuple,
typename IndexSequence>
65template<
template<
typename>
class Filter,
typename T,
typename... Ts,
size_t I,
size_t... Is>
66struct tuple_filter<Filter,
std::tuple<T, Ts...>, std::index_sequence<I, Is...>> {
67 using tail =
typename tuple_filter<Filter, std::tuple<Ts...>, std::index_sequence<Is...>>::type;
68 using type = std::conditional_t<Filter<T>::value,
typename prepend<I, tail>::type, tail>;
71template<
template<
typename>
class Filter>
72struct tuple_filter<Filter,
std::tuple<>, std::index_sequence<>> {
73 using type = std::index_sequence<>;
76template<
typename Tuple,
size_t... I>
77auto tuple_filter_helper(Tuple&& t, std::index_sequence<I...>&&) {
78 return std::make_tuple(std::get<I>(std::forward<Tuple>(t))...);
95template<
template<
typename>
class MapClass,
typename Tuple>
100template<
template<
typename>
class MapClass,
typename... Elements>
102 using type = std::tuple<typename MapClass<Elements>::type...>;
117template<
template<
typename>
class FilterClass,
typename... Elements>
119 using sequence =
typename internal::tuple_filter<FilterClass, std::tuple<Elements...>,
120 std::index_sequence_for<Elements...>>::type;
121 return internal::tuple_filter_helper(t, sequence());
123template<
template<
typename>
class FilterClass,
typename... Elements>
125 using sequence =
typename internal::tuple_filter<FilterClass, std::tuple<Elements...>,
126 std::index_sequence_for<Elements...>>::type;
127 return internal::tuple_filter_helper(std::move(t), sequence());
138template<
typename Function,
typename... Elements>
139auto tuple_map(
const std::tuple<Elements...>& t, Function&& f) {
140 return internal::tuple_map_helper(t, std::forward<Function>(f),
141 std::index_sequence_for<Elements...>());
143template<
typename Function,
typename... Elements>
144auto tuple_map(std::tuple<Elements...>&& t, Function&& f) {
145 return internal::tuple_map_helper(std::move(t), std::forward<Function>(f),
146 std::index_sequence_for<Elements...>());
156template<
typename Function,
typename... Elements>
158 return internal::tuple_for_each_helper(t, std::forward<Function>(f),
159 std::index_sequence_for<Elements...>());
161template<
typename Function,
typename... Elements>
163 return internal::tuple_for_each_helper(t, std::forward<Function>(f),
164 std::index_sequence_for<Elements...>());
166template<
typename Function,
typename... Elements>
168 return internal::tuple_for_each_helper(std::move(t), std::forward<Function>(f),
169 std::index_sequence_for<Elements...>());
auto tuple_map(const std::tuple< Elements... > &t, Function &&f)
Definition: tuple_utils.hh:139
void tuple_for_each(const std::tuple< Elements... > &t, Function &&f)
Definition: tuple_utils.hh:157
auto tuple_filter_by_type(const std::tuple< Elements... > &t)
Definition: tuple_utils.hh:118
Definition: tuple_utils.hh:96
Seastar API namespace.
Definition: abort_on_ebadf.hh:26