summaryrefslogtreecommitdiffstats
path: root/libcxx/test/utilities/tuple
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-12-11 20:47:50 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-12-11 20:47:50 +0000
commit7f64810bc8411fc820ac5ce753a5517b393b81ac (patch)
treec30e7828e0c7a0044178bd5b4d01430ef0f3ad71 /libcxx/test/utilities/tuple
parent5d7e9160e73a05bfbba0349cb37ae4a171b1eba9 (diff)
downloadbcm5719-llvm-7f64810bc8411fc820ac5ce753a5517b393b81ac.tar.gz
bcm5719-llvm-7f64810bc8411fc820ac5ce753a5517b393b81ac.zip
LWG 1385 [FCD] tuple_cat should be a single variadic signature (http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#1385). This issue is only in Ready status, meaning it is not official, but probably will be this March in Madrid. It was tentatively accepted in Batavia with the previso that Bill and I didn't have any problems implementing it. This is my part of that agreement.
llvm-svn: 121619
Diffstat (limited to 'libcxx/test/utilities/tuple')
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp105
1 files changed, 90 insertions, 15 deletions
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
index 7a84c78aa8d..7cfc736fb79 100644
--- a/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
@@ -11,23 +11,11 @@
// template <class... Types> class tuple;
-// template <class... TTypes, class... UTypes>
-// tuple<TTypes..., UTypes...>
-// tuple_cat(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
-//
-// template <class... TTypes, class... UTypes>
-// tuple<TTypes..., UTypes...>
-// tuple_cat(const tuple<TTypes...>&& t, const tuple<UTypes...>& u);
-//
-// template <class... TTypes, class... UTypes>
-// tuple<TTypes..., UTypes...>
-// tuple_cat(const tuple<TTypes...>& t, const tuple<UTypes...>&& u);
-//
-// template <class... TTypes, class... UTypes>
-// tuple<TTypes..., UTypes...>
-// tuple_cat(const tuple<TTypes...>&& t, const tuple<UTypes...>&& u);
+// template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls);
#include <tuple>
+#include <utility>
+#include <array>
#include <string>
#include <cassert>
@@ -36,6 +24,43 @@
int main()
{
{
+ std::tuple<> t = std::tuple_cat();
+ }
+ {
+ std::tuple<> t1;
+ std::tuple<> t2 = std::tuple_cat(t1);
+ }
+ {
+ std::tuple<> t = std::tuple_cat(std::tuple<>());
+ }
+ {
+ std::tuple<> t = std::tuple_cat(std::array<int, 0>());
+ }
+
+ {
+ std::tuple<int> t1(1);
+ std::tuple<int> t = std::tuple_cat(t1);
+ assert(std::get<0>(t) == 1);
+ }
+ {
+ std::tuple<int, MoveOnly> t =
+ std::tuple_cat(std::tuple<int, MoveOnly>(1, 2));
+ assert(std::get<0>(t) == 1);
+ assert(std::get<1>(t) == 2);
+ }
+ {
+ std::tuple<int, int, int> t = std::tuple_cat(std::array<int, 3>());
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 0);
+ assert(std::get<2>(t) == 0);
+ }
+ {
+ std::tuple<int, MoveOnly> t = std::tuple_cat(std::pair<int, MoveOnly>(2, 1));
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == 1);
+ }
+
+ {
std::tuple<> t1;
std::tuple<> t2;
std::tuple<> t3 = std::tuple_cat(t1, t2);
@@ -112,4 +137,54 @@ int main()
assert(std::get<2>(t3) == nullptr);
assert(std::get<3>(t3) == 4);
}
+
+ {
+ std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+ std::tuple<int*, MoveOnly> t2(nullptr, 4);
+ std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
+ std::tuple_cat(std::tuple<>(),
+ std::move(t1),
+ std::move(t2));
+ assert(std::get<0>(t3) == 1);
+ assert(std::get<1>(t3) == 2);
+ assert(std::get<2>(t3) == nullptr);
+ assert(std::get<3>(t3) == 4);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+ std::tuple<int*, MoveOnly> t2(nullptr, 4);
+ std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
+ std::tuple_cat(std::move(t1),
+ std::tuple<>(),
+ std::move(t2));
+ assert(std::get<0>(t3) == 1);
+ assert(std::get<1>(t3) == 2);
+ assert(std::get<2>(t3) == nullptr);
+ assert(std::get<3>(t3) == 4);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+ std::tuple<int*, MoveOnly> t2(nullptr, 4);
+ std::tuple<MoveOnly, MoveOnly, int*, MoveOnly> t3 =
+ std::tuple_cat(std::move(t1),
+ std::move(t2),
+ std::tuple<>());
+ assert(std::get<0>(t3) == 1);
+ assert(std::get<1>(t3) == 2);
+ assert(std::get<2>(t3) == nullptr);
+ assert(std::get<3>(t3) == 4);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly> t1(1, 2);
+ std::tuple<int*, MoveOnly> t2(nullptr, 4);
+ std::tuple<MoveOnly, MoveOnly, int*, MoveOnly, int> t3 =
+ std::tuple_cat(std::move(t1),
+ std::move(t2),
+ std::tuple<int>(5));
+ assert(std::get<0>(t3) == 1);
+ assert(std::get<1>(t3) == 2);
+ assert(std::get<2>(t3) == nullptr);
+ assert(std::get<3>(t3) == 4);
+ assert(std::get<4>(t3) == 5);
+ }
}
OpenPOWER on IntegriCloud