[libcxx-commits] [libcxx] e658b3e - PR43764: Qualify a couple of calls to forward_as_tuple to be ADL-resilient.
David Blaikie via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Oct 28 18:04:49 PDT 2019
Author: David Blaikie
Date: 2019-10-28T18:04:41-07:00
New Revision: e658b3eb9728eb33154233ce09fca39f89d71840
URL: https://github.com/llvm/llvm-project/commit/e658b3eb9728eb33154233ce09fca39f89d71840
DIFF: https://github.com/llvm/llvm-project/commit/e658b3eb9728eb33154233ce09fca39f89d71840.diff
LOG: PR43764: Qualify a couple of calls to forward_as_tuple to be ADL-resilient.
Added:
Modified:
libcxx/include/tuple
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/include/tuple b/libcxx/include/tuple
index e93824f0aa7f..1f80b70759c7 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 b663a4801fea..2fabeb0a577a 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;
}
More information about the libcxx-commits
mailing list