Skip to content

Commit 7a3d904

Browse files
WIP
1 parent 66a88f6 commit 7a3d904

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

libcxx/include/tuple

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,12 +1338,25 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
13381338
}
13391339
};
13401340

1341+
template <class _TupleDst, class _TupleSrc, size_t... _Indices>
1342+
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _TupleDst
1343+
__tuple_cat_select_element_wise(_TupleSrc&& __src, __tuple_indices<_Indices...>) {
1344+
static_assert(tuple_size<_TupleDst>::value == tuple_size<_TupleSrc>::value,
1345+
"misuse of __tuple_cat_select_element_wise with tuples of different sizes");
1346+
return _TupleDst(std::get<_Indices>(std::forward<_TupleSrc>(__src))...);
1347+
}
1348+
13411349
template <class _Tuple0, class... _Tuples>
13421350
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 typename __tuple_cat_return<_Tuple0, _Tuples...>::type
13431351
tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) {
1344-
using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>;
1345-
return __tuple_cat<tuple<>, __tuple_indices<>, typename __make_tuple_indices<tuple_size<_T0>::value>::type>()(
1346-
tuple<>(), std::forward<_Tuple0>(__t0), std::forward<_Tuples>(__tpls)...);
1352+
using _T0 _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tuple0>;
1353+
using _TRet _LIBCPP_NODEBUG = typename __tuple_cat_return<_Tuple0, _Tuples...>::type;
1354+
using _T0Indices _LIBCPP_NODEBUG = typename __make_tuple_indices<tuple_size<_T0>::value>::type;
1355+
using _TRetIndices _LIBCPP_NODEBUG = typename __make_tuple_indices<tuple_size<_TRet>::value>::type;
1356+
return std::__tuple_cat_select_element_wise<_TRet>(
1357+
__tuple_cat<tuple<>, __tuple_indices<>, _T0Indice>()(
1358+
tuple<>(), std::forward<_Tuple0>(__t0), std::forward<_Tuples>(__tpls)...),
1359+
_TRetIndice());
13471360
}
13481361

13491362
template <class... _Tp, class _Alloc>

0 commit comments

Comments
 (0)