PR43764: Qualify a couple of calls to forward_as_tuple to be ADL-resilient.

This commit is contained in:
David Blaikie 2019-10-28 18:03:59 -07:00
parent 8530f294f5
commit e658b3eb97
2 changed files with 29 additions and 11 deletions

View File

@ -1349,8 +1349,9 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type
operator()(tuple<_Types...> __t, _Tuple0&& __t0)
{
return forward_as_tuple(_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
_VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
return _VSTD::forward_as_tuple(
_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
_VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...);
}
template <class _Tuple0, class _Tuple1, class ..._Tuples>
@ -1361,15 +1362,16 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J
typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple0>::type _T0;
typedef _LIBCPP_NODEBUG_TYPE typename remove_reference<_Tuple1>::type _T1;
return __tuple_cat<
tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>,
typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type,
typename __make_tuple_indices<tuple_size<_T1>::value>::type>()
(forward_as_tuple(
_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
_VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...
),
_VSTD::forward<_Tuple1>(__t1),
_VSTD::forward<_Tuples>(__tpls)...);
tuple<_Types...,
typename __apply_cv<_Tuple0, typename tuple_element<
_J0, _T0>::type>::type&&...>,
typename __make_tuple_indices<sizeof...(_Types) +
tuple_size<_T0>::value>::type,
typename __make_tuple_indices<tuple_size<_T1>::value>::type>()(
_VSTD::forward_as_tuple(
_VSTD::forward<_Types>(_VSTD::get<_I0>(__t))...,
_VSTD::get<_J0>(_VSTD::forward<_Tuple0>(__t0))...),
_VSTD::forward<_Tuple1>(__t1), _VSTD::forward<_Tuples>(__tpls)...);
}
};

View File

@ -23,6 +23,14 @@
#include "test_macros.h"
#include "MoveOnly.h"
namespace NS {
struct Namespaced {
int i;
};
template<typename ...Ts>
void forward_as_tuple(Ts...) = delete;
}
int main(int, char**)
{
{
@ -254,5 +262,13 @@ int main(int, char**)
int, const int, int&, const int&>);
((void)r);
}
{
std::tuple<NS::Namespaced> t1({1});
std::tuple<NS::Namespaced> t = std::tuple_cat(t1);
std::tuple<NS::Namespaced, NS::Namespaced> t2 =
std::tuple_cat(t1, t1);
assert(std::get<0>(t).i == 1);
assert(std::get<0>(t2).i == 1);
}
return 0;
}