summaryrefslogtreecommitdiff
path: root/test/std/utilities/tuple/tuple.tuple/tuple.assign
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/utilities/tuple/tuple.tuple/tuple.assign')
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp34
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp89
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp110
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp31
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp104
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp126
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp50
-rw-r--r--test/std/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp34
8 files changed, 0 insertions, 578 deletions
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
deleted file mode 100644
index a66fba22d919f..0000000000000
--- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <tuple>
-
-// template <class... Types> class tuple;
-
-// template <class U1, class U2>
-// tuple& operator=(const pair<U1, U2>& u);
-
-// UNSUPPORTED: c++98, c++03
-
-#include <tuple>
-#include <utility>
-#include <cassert>
-
-int main()
-{
- {
- typedef std::pair<long, char> T0;
- typedef std::tuple<long long, short> T1;
- T0 t0(2, 'a');
- T1 t1;
- t1 = t0;
- assert(std::get<0>(t1) == 2);
- assert(std::get<1>(t1) == short('a'));
- }
-}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
deleted file mode 100644
index 85dcee893a074..0000000000000
--- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <tuple>
-
-// template <class... Types> class tuple;
-
-// template <class... UTypes>
-// tuple& operator=(const tuple<UTypes...>& u);
-
-// UNSUPPORTED: c++98, c++03
-
-#include <tuple>
-#include <string>
-#include <cassert>
-
-struct B
-{
- int id_;
-
- explicit B(int i = 0) : id_(i) {}
-};
-
-struct D
- : B
-{
- explicit D(int i = 0) : B(i) {}
-};
-
-int main()
-{
- {
- typedef std::tuple<long> T0;
- typedef std::tuple<long long> T1;
- T0 t0(2);
- T1 t1;
- t1 = t0;
- assert(std::get<0>(t1) == 2);
- }
- {
- typedef std::tuple<long, char> T0;
- typedef std::tuple<long long, int> T1;
- T0 t0(2, 'a');
- T1 t1;
- t1 = t0;
- assert(std::get<0>(t1) == 2);
- assert(std::get<1>(t1) == int('a'));
- }
- {
- typedef std::tuple<long, char, D> T0;
- typedef std::tuple<long long, int, B> T1;
- T0 t0(2, 'a', D(3));
- T1 t1;
- t1 = t0;
- assert(std::get<0>(t1) == 2);
- assert(std::get<1>(t1) == int('a'));
- assert(std::get<2>(t1).id_ == 3);
- }
- {
- D d(3);
- D d2(2);
- typedef std::tuple<long, char, D&> T0;
- typedef std::tuple<long long, int, B&> T1;
- T0 t0(2, 'a', d2);
- T1 t1(1, 'b', d);
- t1 = t0;
- assert(std::get<0>(t1) == 2);
- assert(std::get<1>(t1) == int('a'));
- assert(std::get<2>(t1).id_ == 2);
- }
- {
- // Test that tuple evaluates correctly applies an lvalue reference
- // before evaluating is_assignable (ie 'is_assignable<int&, int&>')
- // instead of evaluating 'is_assignable<int&&, int&>' which is false.
- int x = 42;
- int y = 43;
- std::tuple<int&&> t(std::move(x));
- std::tuple<int&> t2(y);
- t = t2;
- assert(std::get<0>(t) == 43);
- assert(&std::get<0>(t) == &x);
- }
-}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
deleted file mode 100644
index 1a32acd55cfff..0000000000000
--- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <tuple>
-
-// template <class... Types> class tuple;
-
-// template <class... UTypes>
-// tuple& operator=(tuple<UTypes...>&& u);
-
-// UNSUPPORTED: c++98, c++03
-
-#include <tuple>
-#include <string>
-#include <memory>
-#include <utility>
-#include <cassert>
-
-struct B
-{
- int id_;
-
- explicit B(int i= 0) : id_(i) {}
-
- virtual ~B() {}
-};
-
-struct D
- : B
-{
- explicit D(int i) : B(i) {}
-};
-
-struct E {
- E() = default;
- E& operator=(int) {
- return *this;
- }
-};
-
-int main()
-{
- {
- typedef std::tuple<long> T0;
- typedef std::tuple<long long> T1;
- T0 t0(2);
- T1 t1;
- t1 = std::move(t0);
- assert(std::get<0>(t1) == 2);
- }
- {
- typedef std::tuple<long, char> T0;
- typedef std::tuple<long long, int> T1;
- T0 t0(2, 'a');
- T1 t1;
- t1 = std::move(t0);
- assert(std::get<0>(t1) == 2);
- assert(std::get<1>(t1) == int('a'));
- }
- {
- typedef std::tuple<long, char, D> T0;
- typedef std::tuple<long long, int, B> T1;
- T0 t0(2, 'a', D(3));
- T1 t1;
- t1 = std::move(t0);
- assert(std::get<0>(t1) == 2);
- assert(std::get<1>(t1) == int('a'));
- assert(std::get<2>(t1).id_ == 3);
- }
- {
- D d(3);
- D d2(2);
- typedef std::tuple<long, char, D&> T0;
- typedef std::tuple<long long, int, B&> T1;
- T0 t0(2, 'a', d2);
- T1 t1(1, 'b', d);
- t1 = std::move(t0);
- assert(std::get<0>(t1) == 2);
- assert(std::get<1>(t1) == int('a'));
- assert(std::get<2>(t1).id_ == 2);
- }
- {
- typedef std::tuple<long, char, std::unique_ptr<D>> T0;
- typedef std::tuple<long long, int, std::unique_ptr<B>> T1;
- T0 t0(2, 'a', std::unique_ptr<D>(new D(3)));
- T1 t1;
- t1 = std::move(t0);
- assert(std::get<0>(t1) == 2);
- assert(std::get<1>(t1) == int('a'));
- assert(std::get<2>(t1)->id_ == 3);
- }
- {
- // Test that tuple evaluates correctly applies an lvalue reference
- // before evaluating is_assignable (ie 'is_assignable<int&, int&&>')
- // instead of evaluating 'is_assignable<int&&, int&&>' which is false.
- int x = 42;
- int y = 43;
- std::tuple<int&&, E> t(std::move(x), E{});
- std::tuple<int&&, int> t2(std::move(y), 44);
- t = std::move(t2);
- assert(std::get<0>(t) == 43);
- assert(&std::get<0>(t) == &x);
- }
-}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp
deleted file mode 100644
index 5911391d6cd2b..0000000000000
--- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <tuple>
-
-// template <class... Types> class tuple;
-
-// tuple& operator=(const tuple& u);
-
-// UNSUPPORTED: c++98, c++03
-
-#include <tuple>
-#include <cassert>
-
-#include "MoveOnly.h"
-
-int main()
-{
- {
- typedef std::tuple<MoveOnly> T;
- T t0(MoveOnly(2));
- T t;
- t = t0;
- }
-}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
deleted file mode 100644
index edb235a41919a..0000000000000
--- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <tuple>
-
-// template <class... Types> class tuple;
-
-// tuple& operator=(const tuple& u);
-
-// UNSUPPORTED: c++98, c++03
-
-#include <tuple>
-#include <memory>
-#include <string>
-#include <cassert>
-
-#include "test_macros.h"
-
-struct NonAssignable {
- NonAssignable& operator=(NonAssignable const&) = delete;
- NonAssignable& operator=(NonAssignable&&) = delete;
-};
-struct CopyAssignable {
- CopyAssignable& operator=(CopyAssignable const&) = default;
- CopyAssignable& operator=(CopyAssignable &&) = delete;
-};
-static_assert(std::is_copy_assignable<CopyAssignable>::value, "");
-struct MoveAssignable {
- MoveAssignable& operator=(MoveAssignable const&) = delete;
- MoveAssignable& operator=(MoveAssignable&&) = default;
-};
-
-int main()
-{
- {
- typedef std::tuple<> T;
- T t0;
- T t;
- t = t0;
- }
- {
- typedef std::tuple<int> T;
- T t0(2);
- T t;
- t = t0;
- assert(std::get<0>(t) == 2);
- }
- {
- typedef std::tuple<int, char> T;
- T t0(2, 'a');
- T t;
- t = t0;
- assert(std::get<0>(t) == 2);
- assert(std::get<1>(t) == 'a');
- }
- {
- typedef std::tuple<int, char, std::string> T;
- const T t0(2, 'a', "some text");
- T t;
- t = t0;
- assert(std::get<0>(t) == 2);
- assert(std::get<1>(t) == 'a');
- assert(std::get<2>(t) == "some text");
- }
- {
- // test reference assignment.
- using T = std::tuple<int&, int&&>;
- int x = 42;
- int y = 100;
- int x2 = -1;
- int y2 = 500;
- T t(x, std::move(y));
- T t2(x2, std::move(y2));
- t = t2;
- assert(std::get<0>(t) == x2);
- assert(&std::get<0>(t) == &x);
- assert(std::get<1>(t) == y2);
- assert(&std::get<1>(t) == &y);
- }
- {
- // test that the implicitly generated copy assignment operator
- // is properly deleted
- using T = std::tuple<std::unique_ptr<int>>;
- static_assert(!std::is_copy_assignable<T>::value, "");
- }
- {
- using T = std::tuple<int, NonAssignable>;
- static_assert(!std::is_copy_assignable<T>::value, "");
- }
- {
- using T = std::tuple<int, CopyAssignable>;
- static_assert(std::is_copy_assignable<T>::value, "");
- }
- {
- using T = std::tuple<int, MoveAssignable>;
- static_assert(!std::is_copy_assignable<T>::value, "");
- }
-}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
deleted file mode 100644
index 9bc0ef5015f6d..0000000000000
--- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <tuple>
-
-// template <class... Types> class tuple;
-
-// tuple& operator=(tuple&& u);
-
-// UNSUPPORTED: c++98, c++03
-
-#include <memory>
-#include <tuple>
-#include <utility>
-#include <cassert>
-
-#include "MoveOnly.h"
-
-struct NonAssignable {
- NonAssignable& operator=(NonAssignable const&) = delete;
- NonAssignable& operator=(NonAssignable&&) = delete;
-};
-struct CopyAssignable {
- CopyAssignable& operator=(CopyAssignable const&) = default;
- CopyAssignable& operator=(CopyAssignable&&) = delete;
-};
-static_assert(std::is_copy_assignable<CopyAssignable>::value, "");
-struct MoveAssignable {
- MoveAssignable& operator=(MoveAssignable const&) = delete;
- MoveAssignable& operator=(MoveAssignable&&) = default;
-};
-
-
-struct CountAssign {
- static int copied;
- static int moved;
- static void reset() { copied = moved = 0; }
- CountAssign() = default;
- CountAssign& operator=(CountAssign const&) { ++copied; return *this; }
- CountAssign& operator=(CountAssign&&) { ++moved; return *this; }
-};
-int CountAssign::copied = 0;
-int CountAssign::moved = 0;
-
-
-int main()
-{
- {
- typedef std::tuple<> T;
- T t0;
- T t;
- t = std::move(t0);
- }
- {
- typedef std::tuple<MoveOnly> T;
- T t0(MoveOnly(0));
- T t;
- t = std::move(t0);
- assert(std::get<0>(t) == 0);
- }
- {
- typedef std::tuple<MoveOnly, MoveOnly> T;
- T t0(MoveOnly(0), MoveOnly(1));
- T t;
- t = std::move(t0);
- assert(std::get<0>(t) == 0);
- assert(std::get<1>(t) == 1);
- }
- {
- typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
- T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
- T t;
- t = std::move(t0);
- assert(std::get<0>(t) == 0);
- assert(std::get<1>(t) == 1);
- assert(std::get<2>(t) == 2);
- }
- {
- // test reference assignment.
- using T = std::tuple<int&, int&&>;
- int x = 42;
- int y = 100;
- int x2 = -1;
- int y2 = 500;
- T t(x, std::move(y));
- T t2(x2, std::move(y2));
- t = std::move(t2);
- assert(std::get<0>(t) == x2);
- assert(&std::get<0>(t) == &x);
- assert(std::get<1>(t) == y2);
- assert(&std::get<1>(t) == &y);
- }
- {
- // test that the implicitly generated move assignment operator
- // is properly deleted
- using T = std::tuple<std::unique_ptr<int>>;
- static_assert(std::is_move_assignable<T>::value, "");
- static_assert(!std::is_copy_assignable<T>::value, "");
-
- }
- {
- using T = std::tuple<int, NonAssignable>;
- static_assert(!std::is_move_assignable<T>::value, "");
- }
- {
- using T = std::tuple<int, MoveAssignable>;
- static_assert(std::is_move_assignable<T>::value, "");
- }
- {
- // The move should decay to a copy.
- CountAssign::reset();
- using T = std::tuple<CountAssign, CopyAssignable>;
- static_assert(std::is_move_assignable<T>::value, "");
- T t1;
- T t2;
- t1 = std::move(t2);
- assert(CountAssign::copied == 1);
- assert(CountAssign::moved == 0);
- }
-}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
deleted file mode 100644
index 27656a675982e..0000000000000
--- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
+++ /dev/null
@@ -1,50 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// <tuple>
-
-// template <class... Types> class tuple;
-
-// template <class U1, class U2>
-// tuple& operator=(pair<U1, U2>&& u);
-
-// UNSUPPORTED: c++98, c++03
-
-#include <tuple>
-#include <utility>
-#include <memory>
-#include <cassert>
-
-struct B
-{
- int id_;
-
- explicit B(int i = 0) : id_(i) {}
-
- virtual ~B() {}
-};
-
-struct D
- : B
-{
- explicit D(int i) : B(i) {}
-};
-
-int main()
-{
- {
- typedef std::pair<long, std::unique_ptr<D>> T0;
- typedef std::tuple<long long, std::unique_ptr<B>> T1;
- T0 t0(2, std::unique_ptr<D>(new D(3)));
- T1 t1;
- t1 = std::move(t0);
- assert(std::get<0>(t1) == 2);
- assert(std::get<1>(t1)->id_ == 3);
- }
-}
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp
deleted file mode 100644
index 08d1304f99421..0000000000000
--- a/test/std/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++98, c++03
-
-// <tuple>
-
-// template <class... Types> class tuple;
-
-// template <class Tuple, __tuple_assignable<Tuple, tuple> >
-// tuple & operator=(Tuple &&);
-
-// This test checks that we do not evaluate __make_tuple_types
-// on the array when it doesn't match the size of the tuple.
-
-#include <array>
-#include <tuple>
-
-// Use 1256 to try and blow the template instantiation depth for all compilers.
-typedef std::array<char, 1256> array_t;
-typedef std::tuple<array_t> tuple_t;
-
-int main()
-{
- array_t arr;
- tuple_t tup;
- tup = arr;
-}