17 #ifndef OPENKALMAN_TUPLE_FLATTEN_HPP 18 #define OPENKALMAN_TUPLE_FLATTEN_HPP 20 #include <type_traits> 29 template<
typename Arg> constexpr
auto 30 tuple_flatten_impl(Arg&&);
33 template<
typename Arg, std::size_t...Ix>
38 return
std::tuple_cat(tuple_flatten_impl(
std::
get<Ix>(
std::forward<Arg>(arg)))...);
40 return
std::forward<Arg>(arg);
44 template<typename Arg>
46 tuple_flatten_impl(Arg&& arg)
48 if constexpr (uniformly_gettable<Arg>)
50 constexpr
auto seq = std::make_index_sequence<size_of_v<Arg>>{};
51 return tuple_flatten_impl(std::forward<Arg>(arg), seq);
53 else return std::tuple {std::forward<Arg>(arg)};
63 template<uniformly_gettable Arg>
66 template<
typename Arg, std::enable_if_t<uniformly_gettable<Arg>,
int> = 0>
69 tuple_flatten(Arg&& arg)
71 return detail::tuple_flatten_impl(std::forward<Arg>(arg));
Namespace for collections.
Definition: collections.hpp:27
constexpr bool uniformly_gettable
T is a fixed-size object that is gettable for all indices.
Definition: uniformly_gettable.hpp:55
constexpr detail_get::get_impl< i > get
A generalization of std::get, where the index is known at compile time.
Definition: get.hpp:50
Definition: trait_backports.hpp:64
typename collection_element< i, T >::type collection_element_t
Helper template for collection_element.
Definition: collection_element.hpp:116
Definition for collections::collection_element.
constexpr bool tuple_like
T is a non-empty tuple, pair, array, or other type that acts like a tuple.
Definition: tuple_like.hpp:66