unzipのような
車輪の再発明だと思いますが、sprout::array<sprout::tuple<Types...>>からsprout::tuple<sprout::array<Types>...>を作って返す関数を実装してみました。アイデアはHaskellのunzip関数です。
Wandbox http://melpon.org/wandbox/permlink/aRxrOWetWilTbwZ3
#include <sprout/tuple.hpp> #include <sprout/array.hpp> #include <sprout/index_tuple.hpp> template <std::size_t N, class Type, class... Types> constexpr auto unzip_impl2(const Types&... elems) { return sprout::make_array<Type>(sprout::get<N>(elems)...); } template <sprout::index_t... ArrayIndices, sprout::index_t... TupleIndices, class... Types, std::size_t N> constexpr auto unzip_impl( const sprout::index_tuple<ArrayIndices...>&, const sprout::index_tuple<TupleIndices...>&, const sprout::array<sprout::tuple<Types...>, N>& zipped) { return sprout::make_tuple( unzip_impl2<TupleIndices, Types>(zipped[ArrayIndices]...)...); } template <class... Types, std::size_t N> constexpr auto unzip(const sprout::array<sprout::tuple<Types...>, N>& zipped) { return unzip_impl(sprout::index_range<0, N>::make(), sprout::index_range<0, sizeof...(Types)>::make(), zipped); } int main() { constexpr auto zipped = sprout::make_common_array(sprout::make_tuple(1, 'a'), sprout::make_tuple(2, 'b'), sprout::make_tuple(3, 'c')); constexpr auto unzipped = unzip(zipped); static_assert(sprout::get<0>(unzipped)[0] == 1, ""); static_assert(sprout::get<0>(unzipped)[1] == 2, ""); static_assert(sprout::get<0>(unzipped)[2] == 3, ""); static_assert(sprout::get<1>(unzipped)[0] == 'a', ""); static_assert(sprout::get<1>(unzipped)[1] == 'b', ""); static_assert(sprout::get<1>(unzipped)[2] == 'c', ""); }