Index: include/tuple =================================================================== --- include/tuple +++ include/tuple @@ -1370,9 +1370,33 @@ typename __make_tuple_indices>>::type{}) ) +template +struct __is_rvalue_tuple : false_type { }; + +template +struct __is_rvalue_tuple> : true_type { }; + +template +struct __is_rvalue_tuple &> : true_type { }; + +template +struct __is_rvalue_tuple> : true_type { }; + +template +struct __is_rvalue_tuple &> : true_type { }; + template -inline _LIBCPP_INLINE_VISIBILITY -constexpr _Tp __make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>) +inline _LIBCPP_INLINE_VISIBILITY constexpr +typename enable_if<__is_rvalue_tuple<_Tuple>::value, _Tp>::type +__make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>) +_LIBCPP_NOEXCEPT_RETURN( + _Tp(_VSTD::move(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t)))...) +) + +template +inline _LIBCPP_INLINE_VISIBILITY constexpr +typename enable_if::value, _Tp>::type +__make_from_tuple_impl(_Tuple&& __t, __tuple_indices<_Idx...>) _LIBCPP_NOEXCEPT_RETURN( _Tp(_VSTD::get<_Idx>(_VSTD::forward<_Tuple>(__t))...) ) @@ -1381,7 +1405,7 @@ inline _LIBCPP_INLINE_VISIBILITY constexpr _Tp make_from_tuple(_Tuple&& __t) _LIBCPP_NOEXCEPT_RETURN( - _VSTD::__make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t), + __make_from_tuple_impl<_Tp>(_VSTD::forward<_Tuple>(__t), typename __make_tuple_indices>>::type{}) ) Index: test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp =================================================================== --- test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp +++ test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp @@ -156,6 +156,13 @@ assert((do_forwarding_test(std::move(tup)))); assert((do_forwarding_test(std::move(ctup)))); } + // test with pair + { + using Tup = std::tuple; + int x = 42; + Tup tup(std::move(x), std::move(x)); + assert((do_forwarding_test(tup))); + } } void test_noexcept() { @@ -211,5 +218,5 @@ test_perfect_forwarding(); test_noexcept(); - return 0; + return 0; }