diff options
author | David Blaikie <dblaikie@gmail.com> | 2019-10-28 18:03:59 -0700 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2019-10-28 18:04:41 -0700 |
commit | e658b3eb9728eb33154233ce09fca39f89d71840 (patch) | |
tree | b14913a6e33d57cfcfeebdff783075c5f03a38d7 | |
parent | 8530f294f59a36e2188e2198275490e1d6616e7f (diff) | |
download | bcm5719-llvm-e658b3eb9728eb33154233ce09fca39f89d71840.tar.gz bcm5719-llvm-e658b3eb9728eb33154233ce09fca39f89d71840.zip |
PR43764: Qualify a couple of calls to forward_as_tuple to be ADL-resilient.
-rw-r--r-- | libcxx/include/tuple | 24 | ||||
-rw-r--r-- | libcxx/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp | 16 |
2 files changed, 29 insertions, 11 deletions
diff --git a/libcxx/include/tuple b/libcxx/include/tuple index e93824f0aa7..1f80b70759c 100644 --- a/libcxx/include/tuple +++ b/libcxx/include/tuple @@ -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)...); } }; diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp index b663a4801fe..2fabeb0a577 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp @@ -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; } |