[Solved] Transform std::pair to std::tuple with any number of elements
Option #1 #include <cstddef> #include <type_traits> #include <utility> #include <tuple> template <typename A, typename B> struct merge_tuples { static_assert(std::tuple_size<A>::value == std::tuple_size<B>::value, “!”); template <std::size_t… Is> static auto merge(std::index_sequence<Is…>) noexcept -> std::tuple<typename std::decay<decltype(std::declval<typename std::tuple_element<Is, A>::type>() + std::declval<typename std::tuple_element<Is, B>::type>()) >::type…>; using type = decltype(merge(std::make_index_sequence<std::tuple_size<A>::value>{})); }; DEMO Option #2 #include <type_traits> #include <utility> template <typename A, typename … Read more