[libcxx-commits] [libcxx] r359255 - Fix return type of std::tuple_cat.
Eric Fiselier via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Apr 25 18:02:18 PDT 2019
Author: ericwf
Date: Thu Apr 25 18:02:18 2019
New Revision: 359255
URL: http://llvm.org/viewvc/llvm-project?rev=359255&view=rev
Log:
Fix return type of std::tuple_cat.
When the arguments to tuple cat were const, the const was incorrectly
propagated into the type of the resulting tuple. For example:
const std::tuple<int> t(42);
auto r = std::tuple_cat(t, t);
// Incorrect! should be std::tuple<int, int>.
static_assert(is_same_v<decltype(r), std::tuple<const int, const int>>);
Modified:
libcxx/trunk/include/tuple
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
Modified: libcxx/trunk/include/tuple
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=359255&r1=359254&r2=359255&view=diff
==============================================================================
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Thu Apr 25 18:02:18 2019
@@ -1211,7 +1211,7 @@ template <class ..._Types, class _Tuple0
struct __tuple_cat_return_1<tuple<_Types...>, true, _Tuple0>
{
typedef typename __tuple_cat_type<tuple<_Types...>,
- typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type>::type
+ typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type>::type
type;
};
@@ -1220,7 +1220,7 @@ struct __tuple_cat_return_1<tuple<_Types
: public __tuple_cat_return_1<
typename __tuple_cat_type<
tuple<_Types...>,
- typename __make_tuple_types<typename remove_reference<_Tuple0>::type>::type
+ typename __make_tuple_types<typename __uncvref<_Tuple0>::type>::type
>::type,
__tuple_like<typename remove_reference<_Tuple1>::type>::value,
_Tuple1, _Tuples...>
Modified: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp?rev=359255&r1=359254&r2=359255&view=diff
==============================================================================
--- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp (original)
+++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp Thu Apr 25 18:02:18 2019
@@ -238,6 +238,21 @@ int main(int, char**)
);
assert(t2 == std::make_tuple(std::make_tuple(1), std::make_tuple(2)));
}
+ {
+ int x = 101;
+ std::tuple<int, int&, const int&, int&&> t(42, x, x, std::move(x));
+ const auto& ct = t;
+ std::tuple<int, int&, const int&> t2(42, x, x);
+ const auto& ct2 = t2;
+ auto r = std::tuple_cat(std::move(t), std::move(ct), t2, ct2);
+
+ ASSERT_SAME_TYPE(decltype(r), std::tuple<
+ int, int&, const int&, int&&,
+ int, int&, const int&, int&&,
+ int, int&, const int&,
+ int, int&, const int&>);
+ ((void)r);
+ }
return 0;
}
More information about the libcxx-commits
mailing list