summaryrefslogtreecommitdiffstats
path: root/libcxx/test/utilities/tuple/tuple.tuple
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/utilities/tuple/tuple.tuple')
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/DefaultOnly.h26
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/MoveOnly.h41
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/alloc_first.h49
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/alloc_last.h49
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/allocators.h176
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/empty_member.pass.cpp44
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp32
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp75
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp88
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp29
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp52
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp53
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp49
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp27
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp55
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp79
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp71
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp74
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp57
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp67
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp82
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp76
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp75
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp54
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp26
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp62
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp25
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp30
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp70
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp82
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp28
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp48
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp49
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp49
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp47
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp41
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp30
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp115
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp39
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp48
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp56
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp47
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp43
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.range/begin.pass.cpp33
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp144
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp196
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp60
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp59
-rw-r--r--libcxx/test/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp44
49 files changed, 2951 insertions, 0 deletions
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/DefaultOnly.h b/libcxx/test/utilities/tuple/tuple.tuple/DefaultOnly.h
new file mode 100644
index 00000000000..d40e9c13446
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/DefaultOnly.h
@@ -0,0 +1,26 @@
+#ifndef DEFAULTONLY_H
+#define DEFAULTONLY_H
+
+#include <cassert>
+
+class DefaultOnly
+{
+ int data_;
+
+ DefaultOnly(const DefaultOnly&);
+ DefaultOnly& operator=(const DefaultOnly&);
+public:
+ static int count;
+
+ DefaultOnly() : data_(-1) {++count;}
+ ~DefaultOnly() {data_ = 0; --count;}
+
+ friend bool operator==(const DefaultOnly& x, const DefaultOnly& y)
+ {return x.data_ == y.data_;}
+ friend bool operator< (const DefaultOnly& x, const DefaultOnly& y)
+ {return x.data_ < y.data_;}
+};
+
+int DefaultOnly::count = 0;
+
+#endif
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/MoveOnly.h b/libcxx/test/utilities/tuple/tuple.tuple/MoveOnly.h
new file mode 100644
index 00000000000..b7d62b71374
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/MoveOnly.h
@@ -0,0 +1,41 @@
+#ifndef MOVEONLY_H
+#define MOVEONLY_H
+
+#ifdef _LIBCPP_MOVE
+
+#include <cstddef>
+#include <functional>
+
+class MoveOnly
+{
+ MoveOnly(const MoveOnly&);
+ MoveOnly& operator=(const MoveOnly&);
+
+ int data_;
+public:
+ MoveOnly(int data = 1) : data_(data) {}
+ MoveOnly(MoveOnly&& x)
+ : data_(x.data_) {x.data_ = 0;}
+ MoveOnly& operator=(MoveOnly&& x)
+ {data_ = x.data_; x.data_ = 0; return *this;}
+
+ int get() const {return data_;}
+
+ bool operator==(const MoveOnly& x) const {return data_ == x.data_;}
+ bool operator< (const MoveOnly& x) const {return data_ < x.data_;}
+};
+
+namespace std {
+
+template <>
+struct hash<MoveOnly>
+ : public std::unary_function<MoveOnly, std::size_t>
+{
+ std::size_t operator()(const MoveOnly& x) const {return x.get();}
+};
+
+}
+
+#endif
+
+#endif
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/alloc_first.h b/libcxx/test/utilities/tuple/tuple.tuple/alloc_first.h
new file mode 100644
index 00000000000..2b2183a4502
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/alloc_first.h
@@ -0,0 +1,49 @@
+#ifndef ALLOC_FIRST_H
+#define ALLOC_FIRST_H
+
+#include <cassert>
+
+#include "allocators.h"
+
+struct alloc_first
+{
+ static bool allocator_constructed;
+
+ typedef A1<int> allocator_type;
+
+ int data_;
+
+ alloc_first() : data_(0) {}
+ alloc_first(int d) : data_(d) {}
+ alloc_first(std::allocator_arg_t, const A1<int>& a)
+ : data_(0)
+ {
+ assert(a.id() == 5);
+ allocator_constructed = true;
+ }
+
+ alloc_first(std::allocator_arg_t, const A1<int>& a, int d)
+ : data_(d)
+ {
+ assert(a.id() == 5);
+ allocator_constructed = true;
+ }
+
+ alloc_first(std::allocator_arg_t, const A1<int>& a, const alloc_first& d)
+ : data_(d.data_)
+ {
+ assert(a.id() == 5);
+ allocator_constructed = true;
+ }
+
+ ~alloc_first() {data_ = -1;}
+
+ friend bool operator==(const alloc_first& x, const alloc_first& y)
+ {return x.data_ == y.data_;}
+ friend bool operator< (const alloc_first& x, const alloc_first& y)
+ {return x.data_ < y.data_;}
+};
+
+bool alloc_first::allocator_constructed = false;
+
+#endif
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/alloc_last.h b/libcxx/test/utilities/tuple/tuple.tuple/alloc_last.h
new file mode 100644
index 00000000000..7601c9d8714
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/alloc_last.h
@@ -0,0 +1,49 @@
+#ifndef ALLOC_LAST_H
+#define ALLOC_LAST_H
+
+#include <cassert>
+
+#include "allocators.h"
+
+struct alloc_last
+{
+ static bool allocator_constructed;
+
+ typedef A1<int> allocator_type;
+
+ int data_;
+
+ alloc_last() : data_(0) {}
+ alloc_last(int d) : data_(d) {}
+ alloc_last(const A1<int>& a)
+ : data_(0)
+ {
+ assert(a.id() == 5);
+ allocator_constructed = true;
+ }
+
+ alloc_last(int d, const A1<int>& a)
+ : data_(d)
+ {
+ assert(a.id() == 5);
+ allocator_constructed = true;
+ }
+
+ alloc_last(const alloc_last& d, const A1<int>& a)
+ : data_(d.data_)
+ {
+ assert(a.id() == 5);
+ allocator_constructed = true;
+ }
+
+ ~alloc_last() {data_ = -1;}
+
+ friend bool operator==(const alloc_last& x, const alloc_last& y)
+ {return x.data_ == y.data_;}
+ friend bool operator< (const alloc_last& x, const alloc_last& y)
+ {return x.data_ < y.data_;}
+};
+
+bool alloc_last::allocator_constructed = false;
+
+#endif
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/allocators.h b/libcxx/test/utilities/tuple/tuple.tuple/allocators.h
new file mode 100644
index 00000000000..7075f85e222
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/allocators.h
@@ -0,0 +1,176 @@
+#ifndef ALLOCATORS_H
+#define ALLOCATORS_H
+
+#include <type_traits>
+#include <utility>
+
+#ifdef _LIBCPP_MOVE
+
+template <class T>
+class A1
+{
+ int id_;
+public:
+ explicit A1(int id = 0) : id_(id) {}
+
+ typedef T value_type;
+
+ int id() const {return id_;}
+
+ static bool copy_called;
+ static bool move_called;
+ static bool allocate_called;
+ static std::pair<T*, std::size_t> deallocate_called;
+
+ A1(const A1& a) : id_(a.id()) {copy_called = true;}
+ A1(A1&& a) : id_(a.id()) {move_called = true;}
+
+ template <class U>
+ A1(const A1<U>& a) : id_(a.id()) {copy_called = true;}
+ template <class U>
+ A1(A1<U>&& a) : id_(a.id()) {move_called = true;}
+
+ T* allocate(std::size_t n)
+ {
+ allocate_called = true;
+ return (T*)n;
+ }
+
+ void deallocate(T* p, std::size_t n)
+ {
+ deallocate_called = std::pair<T*, std::size_t>(p, n);
+ }
+
+ std::size_t max_size() const {return id_;}
+};
+
+template <class T> bool A1<T>::copy_called = false;
+template <class T> bool A1<T>::move_called = false;
+template <class T> bool A1<T>::allocate_called = false;
+template <class T> std::pair<T*, std::size_t> A1<T>::deallocate_called;
+
+template <class T, class U>
+inline
+bool operator==(const A1<T>& x, const A1<U>& y)
+{
+ return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A1<T>& x, const A1<U>& y)
+{
+ return !(x == y);
+}
+
+template <class T>
+class A2
+{
+ int id_;
+public:
+ explicit A2(int id = 0) : id_(id) {}
+
+ typedef T value_type;
+
+ typedef unsigned size_type;
+ typedef int difference_type;
+
+ typedef std::true_type propagate_on_container_move_assignment;
+
+ int id() const {return id_;}
+
+ static bool copy_called;
+ static bool move_called;
+ static bool allocate_called;
+
+ A2(const A2& a) : id_(a.id()) {copy_called = true;}
+ A2(A2&& a) : id_(a.id()) {move_called = true;}
+
+ T* allocate(std::size_t n, const void* hint)
+ {
+ allocate_called = true;
+ return (T*)hint;
+ }
+};
+
+template <class T> bool A2<T>::copy_called = false;
+template <class T> bool A2<T>::move_called = false;
+template <class T> bool A2<T>::allocate_called = false;
+
+template <class T, class U>
+inline
+bool operator==(const A2<T>& x, const A2<U>& y)
+{
+ return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A2<T>& x, const A2<U>& y)
+{
+ return !(x == y);
+}
+
+template <class T>
+class A3
+{
+ int id_;
+public:
+ explicit A3(int id = 0) : id_(id) {}
+
+ typedef T value_type;
+
+ typedef std::true_type propagate_on_container_copy_assignment;
+ typedef std::true_type propagate_on_container_swap;
+
+ int id() const {return id_;}
+
+ static bool copy_called;
+ static bool move_called;
+ static bool constructed;
+ static bool destroy_called;
+
+ A3(const A3& a) : id_(a.id()) {copy_called = true;}
+ A3(A3&& a) : id_(a.id()) {move_called = true;}
+
+ template <class U, class ...Args>
+ void construct(U* p, Args&& ...args)
+ {
+ ::new (p) U(std::forward<Args>(args)...);
+ constructed = true;
+ }
+
+ template <class U>
+ void destroy(U* p)
+ {
+ p->~U();
+ destroy_called = true;
+ }
+
+ A3 select_on_container_copy_construction() const {return A3(-1);}
+};
+
+
+
+template <class T> bool A3<T>::copy_called = false;
+template <class T> bool A3<T>::move_called = false;
+template <class T> bool A3<T>::constructed = false;
+template <class T> bool A3<T>::destroy_called = false;
+
+template <class T, class U>
+inline
+bool operator==(const A3<T>& x, const A3<U>& y)
+{
+ return x.id() == y.id();
+}
+
+template <class T, class U>
+inline
+bool operator!=(const A3<T>& x, const A3<U>& y)
+{
+ return !(x == y);
+}
+
+#endif
+
+#endif
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/empty_member.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/empty_member.pass.cpp
new file mode 100644
index 00000000000..53783cc8b96
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/empty_member.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// This is not a portable test
+
+#include <tuple>
+
+struct A {};
+
+struct B {};
+
+int main()
+{
+ {
+ typedef std::tuple<int, A> T;
+ static_assert((sizeof(T) == sizeof(int)), "");
+ }
+ {
+ typedef std::tuple<A, int> T;
+ static_assert((sizeof(T) == sizeof(int)), "");
+ }
+ {
+ typedef std::tuple<A, int, B> T;
+ static_assert((sizeof(T) == sizeof(int)), "");
+ }
+ {
+ typedef std::tuple<A, B, int> T;
+ static_assert((sizeof(T) == sizeof(int)), "");
+ }
+ {
+ typedef std::tuple<int, A, B> T;
+ static_assert((sizeof(T) == sizeof(int)), "");
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
new file mode 100644
index 00000000000..b1c98599da0
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2>
+// tuple& operator=(const pair<U1, U2>& u);
+
+#include <tuple>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<double, char> T0;
+ typedef std::tuple<int, short> T1;
+ T0 t0(2.5, 'a');
+ T1 t1;
+ t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == short('a'));
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
new file mode 100644
index 00000000000..b47d4b62671
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+// tuple& operator=(const tuple<UTypes...>& u);
+
+#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<double> T0;
+ typedef std::tuple<int> T1;
+ T0 t0(2.5);
+ T1 t1;
+ t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ }
+ {
+ typedef std::tuple<double, char> T0;
+ typedef std::tuple<int, int> T1;
+ T0 t0(2.5, 'a');
+ T1 t1;
+ t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ }
+ {
+ typedef std::tuple<double, char, D> T0;
+ typedef std::tuple<int, int, B> T1;
+ T0 t0(2.5, '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<double, char, D&> T0;
+ typedef std::tuple<int, int, B&> T1;
+ T0 t0(2.5, 'a', d2);
+ T1 t1(1.5, 'b', d);
+ t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ assert(std::get<2>(t1).id_ == 2);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
new file mode 100644
index 00000000000..7c599072df1
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+// tuple& operator=(tuple<UTypes...>&& u);
+
+#include <tuple>
+#include <string>
+#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::tuple<double> T0;
+ typedef std::tuple<int> T1;
+ T0 t0(2.5);
+ T1 t1;
+ t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ }
+ {
+ typedef std::tuple<double, char> T0;
+ typedef std::tuple<int, int> T1;
+ T0 t0(2.5, 'a');
+ T1 t1;
+ t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ }
+ {
+ typedef std::tuple<double, char, D> T0;
+ typedef std::tuple<int, int, B> T1;
+ T0 t0(2.5, '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<double, char, D&> T0;
+ typedef std::tuple<int, int, B&> T1;
+ T0 t0(2.5, 'a', d2);
+ T1 t1(1.5, '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<double, char, std::unique_ptr<D>> T0;
+ typedef std::tuple<int, int, std::unique_ptr<B>> T1;
+ T0 t0(2.5, '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);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp
new file mode 100644
index 00000000000..39a6a1a4597
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/copy.fail.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple& operator=(const tuple& u);
+
+#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/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
new file mode 100644
index 00000000000..70604bfee7a
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple& operator=(const tuple& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+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;
+ 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");
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
new file mode 100644
index 00000000000..423e9bfa3e2
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple& operator=(tuple&& u);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+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);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
new file mode 100644
index 00000000000..886efdaed1d
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2>
+// tuple& operator=(pair<U1, U2>&& u);
+
+#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<double, std::unique_ptr<D>> T0;
+ typedef std::tuple<int, std::unique_ptr<B>> T1;
+ T0 t0(2.5, 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/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp
new file mode 100644
index 00000000000..65c2fa63ea3
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.fail.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+// explicit tuple(UTypes&&... u);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+ {
+ std::tuple<MoveOnly> t = MoveOnly(0);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
new file mode 100644
index 00000000000..43416afbf05
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/UTypes.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes>
+// explicit tuple(UTypes&&... u);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+ {
+ std::tuple<MoveOnly> t(MoveOnly(0));
+ assert(std::get<0>(t) == 0);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly> t(MoveOnly(0), MoveOnly(1));
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0),
+ MoveOnly(1),
+ MoveOnly(2));
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ assert(std::get<2>(t) == 2);
+ }
+ // extensions
+ {
+ std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0),
+ MoveOnly(1));
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ assert(std::get<2>(t) == MoveOnly());
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly, MoveOnly> t(MoveOnly(0));
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == MoveOnly());
+ assert(std::get<2>(t) == MoveOnly());
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
new file mode 100644
index 00000000000..e9ad4524b7d
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+// tuple(allocator_arg_t, const Alloc& a);
+
+#include <tuple>
+#include <cassert>
+
+#include "../DefaultOnly.h"
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+ {
+ std::tuple<> t(std::allocator_arg, A1<int>());
+ }
+ {
+ std::tuple<int> t(std::allocator_arg, A1<int>());
+ assert(std::get<0>(t) == 0);
+ }
+ {
+ std::tuple<DefaultOnly> t(std::allocator_arg, A1<int>());
+ assert(std::get<0>(t) == DefaultOnly());
+ }
+ {
+ assert(!alloc_first::allocator_constructed);
+ std::tuple<alloc_first> t(std::allocator_arg, A1<int>(5));
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t) == alloc_first());
+ }
+ {
+ assert(!alloc_last::allocator_constructed);
+ std::tuple<alloc_last> t(std::allocator_arg, A1<int>(5));
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t) == alloc_last());
+ }
+ {
+ alloc_first::allocator_constructed = false;
+ std::tuple<DefaultOnly, alloc_first> t(std::allocator_arg, A1<int>(5));
+ assert(std::get<0>(t) == DefaultOnly());
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<1>(t) == alloc_first());
+ }
+ {
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ std::tuple<DefaultOnly, alloc_first, alloc_last> t(std::allocator_arg,
+ A1<int>(5));
+ assert(std::get<0>(t) == DefaultOnly());
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<1>(t) == alloc_first());
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<2>(t) == alloc_last());
+ }
+ {
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ std::tuple<DefaultOnly, alloc_first, alloc_last> t(std::allocator_arg,
+ A2<int>(5));
+ assert(std::get<0>(t) == DefaultOnly());
+ assert(!alloc_first::allocator_constructed);
+ assert(std::get<1>(t) == alloc_first());
+ assert(!alloc_last::allocator_constructed);
+ assert(std::get<2>(t) == alloc_last());
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
new file mode 100644
index 00000000000..c3e09b9b5a4
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class... UTypes>
+// tuple(allocator_arg_t, const Alloc& a, UTypes&&...);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+ {
+ std::tuple<MoveOnly> t(std::allocator_arg, A1<int>(), MoveOnly(0));
+ assert(std::get<0>(t) == 0);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
+ MoveOnly(0), MoveOnly(1));
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
+ MoveOnly(0),
+ 1, 2);
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ assert(std::get<2>(t) == 2);
+ }
+ {
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
+ A1<int>(5), 1, 2, 3);
+ assert(std::get<0>(t) == 1);
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<1>(t) == alloc_first(2));
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<2>(t) == alloc_last(3));
+ }
+ // extensions
+ {
+ std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
+ 0, 1);
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ assert(std::get<2>(t) == MoveOnly());
+ }
+ {
+ std::tuple<MoveOnly, MoveOnly, MoveOnly> t(std::allocator_arg, A1<int>(),
+ 0);
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == MoveOnly());
+ assert(std::get<2>(t) == MoveOnly());
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp
new file mode 100644
index 00000000000..d32e62d805e
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_Types.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+// tuple(allocator_arg_t, const Alloc& a, const Types&...);
+
+#include <tuple>
+#include <cassert>
+
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+ {
+ std::tuple<int> t(std::allocator_arg, A1<int>(), 3);
+ assert(std::get<0>(t) == 3);
+ }
+ {
+ assert(!alloc_first::allocator_constructed);
+ std::tuple<alloc_first> t(std::allocator_arg, A1<int>(5), alloc_first(3));
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t) == alloc_first(3));
+ }
+ {
+ assert(!alloc_last::allocator_constructed);
+ std::tuple<alloc_last> t(std::allocator_arg, A1<int>(5), alloc_last(3));
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t) == alloc_last(3));
+ }
+ {
+ alloc_first::allocator_constructed = false;
+ std::tuple<int, alloc_first> t(std::allocator_arg, A1<int>(5),
+ 10, alloc_first(15));
+ assert(std::get<0>(t) == 10);
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<1>(t) == alloc_first(15));
+ }
+ {
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
+ A1<int>(5), 1, alloc_first(2),
+ alloc_last(3));
+ assert(std::get<0>(t) == 1);
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<1>(t) == alloc_first(2));
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<2>(t) == alloc_last(3));
+ }
+ {
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ std::tuple<int, alloc_first, alloc_last> t(std::allocator_arg,
+ A2<int>(5), 1, alloc_first(2),
+ alloc_last(3));
+ assert(std::get<0>(t) == 1);
+ assert(!alloc_first::allocator_constructed);
+ assert(std::get<1>(t) == alloc_first(2));
+ assert(!alloc_last::allocator_constructed);
+ assert(std::get<2>(t) == alloc_last(3));
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp
new file mode 100644
index 00000000000..00ee35add78
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_const_pair.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class U1, class U2>
+// tuple(allocator_arg_t, const Alloc& a, const pair<U1, U2>&);
+
+#include <tuple>
+#include <utility>
+#include <cassert>
+
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+ {
+ typedef std::pair<double, int> T0;
+ typedef std::tuple<int, double> T1;
+ T0 t0(2, 3);
+ T1 t1(std::allocator_arg, A1<int>(5), t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == 3);
+ }
+ {
+ typedef std::pair<int, int> T0;
+ typedef std::tuple<alloc_first, double> T1;
+ T0 t0(2, 3);
+ alloc_first::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == 3);
+ }
+ {
+ typedef std::pair<int, int> T0;
+ typedef std::tuple<alloc_first, alloc_last> T1;
+ T0 t0(2, 3);
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == 3);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp
new file mode 100644
index 00000000000..4b5310a735f
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_copy.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class... UTypes>
+// tuple(allocator_arg_t, const Alloc& a, const tuple<UTypes...>&);
+
+#include <tuple>
+#include <cassert>
+
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+ {
+ typedef std::tuple<double> T0;
+ typedef std::tuple<int> T1;
+ T0 t0(2.5);
+ T1 t1(std::allocator_arg, A1<int>(), t0);
+ assert(std::get<0>(t1) == 2);
+ }
+ {
+ typedef std::tuple<int> T0;
+ typedef std::tuple<alloc_first> T1;
+ T0 t0(2);
+ alloc_first::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t1) == 2);
+ }
+ {
+ typedef std::tuple<int, int> T0;
+ typedef std::tuple<alloc_first, alloc_last> T1;
+ T0 t0(2, 3);
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == 3);
+ }
+ {
+ typedef std::tuple<double, int, int> T0;
+ typedef std::tuple<int, alloc_first, alloc_last> T1;
+ T0 t0(1.5, 2, 3);
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t1) == 1);
+ assert(std::get<1>(t1) == 2);
+ assert(std::get<2>(t1) == 3);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp
new file mode 100644
index 00000000000..2c3c5dcc1d2
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_convert_move.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class... UTypes>
+// tuple(allocator_arg_t, const Alloc& a, tuple<UTypes...>&&);
+
+#include <tuple>
+#include <string>
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+struct B
+{
+ int id_;
+
+ explicit B(int i) : id_(i) {}
+
+ virtual ~B() {}
+};
+
+struct D
+ : B
+{
+ explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+ {
+ typedef std::tuple<int> T0;
+ typedef std::tuple<alloc_first> T1;
+ T0 t0(2);
+ alloc_first::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t1) == 2);
+ }
+ {
+ typedef std::tuple<std::unique_ptr<D>> T0;
+ typedef std::tuple<std::unique_ptr<B>> T1;
+ T0 t0(std::unique_ptr<D>(new D(3)));
+ T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(std::get<0>(t1)->id_ == 3);
+ }
+ {
+ typedef std::tuple<int, std::unique_ptr<D>> T0;
+ typedef std::tuple<alloc_first, std::unique_ptr<B>> T1;
+ T0 t0(2, std::unique_ptr<D>(new D(3)));
+ alloc_first::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1)->id_ == 3);
+ }
+ {
+ typedef std::tuple<int, int, std::unique_ptr<D>> T0;
+ typedef std::tuple<alloc_last, alloc_first, std::unique_ptr<B>> T1;
+ T0 t0(1, 2, std::unique_ptr<D>(new D(3)));
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_first::allocator_constructed);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t1) == 1);
+ assert(std::get<1>(t1) == 2);
+ assert(std::get<2>(t1)->id_ == 3);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp
new file mode 100644
index 00000000000..2bb2bc05fa1
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_copy.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+// tuple(allocator_arg_t, const Alloc& a, const tuple&);
+
+#include <tuple>
+#include <cassert>
+
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ T t0;
+ T t(std::allocator_arg, A1<int>(), t0);
+ }
+ {
+ typedef std::tuple<int> T;
+ T t0(2);
+ T t(std::allocator_arg, A1<int>(), t0);
+ assert(std::get<0>(t) == 2);
+ }
+ {
+ typedef std::tuple<alloc_first> T;
+ T t0(2);
+ alloc_first::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t) == 2);
+ }
+ {
+ typedef std::tuple<alloc_last> T;
+ T t0(2);
+ alloc_last::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t) == 2);
+ }
+ {
+ typedef std::tuple<alloc_first, alloc_last> T;
+ T t0(2, 3);
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == 3);
+ }
+ {
+ typedef std::tuple<int, alloc_first, alloc_last> T;
+ T t0(1, 2, 3);
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), t0);
+ assert(alloc_first::allocator_constructed);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t) == 1);
+ assert(std::get<1>(t) == 2);
+ assert(std::get<2>(t) == 3);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp
new file mode 100644
index 00000000000..938230bd3c2
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc>
+// tuple(allocator_arg_t, const Alloc& a, tuple&&);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ T t0;
+ T t(std::allocator_arg, A1<int>(), std::move(t0));
+ }
+ {
+ typedef std::tuple<MoveOnly> T;
+ T t0(MoveOnly(0));
+ T t(std::allocator_arg, A1<int>(), std::move(t0));
+ assert(std::get<0>(t) == 0);
+ }
+ {
+ typedef std::tuple<alloc_first> T;
+ T t0(1);
+ alloc_first::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t) == 1);
+ }
+ {
+ typedef std::tuple<alloc_last> T;
+ T t0(1);
+ alloc_last::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t) == 1);
+ }
+ {
+ typedef std::tuple<MoveOnly, alloc_first> T;
+ T t0(0 ,1);
+ alloc_first::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ }
+ {
+ typedef std::tuple<MoveOnly, alloc_first, alloc_last> T;
+ T t0(1, 2, 3);
+ alloc_first::allocator_constructed = false;
+ alloc_last::allocator_constructed = false;
+ T t(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_first::allocator_constructed);
+ assert(alloc_last::allocator_constructed);
+ assert(std::get<0>(t) == 1);
+ assert(std::get<1>(t) == 2);
+ assert(std::get<2>(t) == 3);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp
new file mode 100644
index 00000000000..d04c946c8cf
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_move_pair.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class Alloc, class U1, class U2>
+// tuple(allocator_arg_t, const Alloc& a, pair<U1, U2>&&);
+
+#include <tuple>
+#include <utility>
+#include <memory>
+#include <cassert>
+
+#include "../allocators.h"
+#include "../alloc_first.h"
+#include "../alloc_last.h"
+
+struct B
+{
+ int id_;
+
+ explicit B(int i) : id_(i) {}
+
+ virtual ~B() {}
+};
+
+struct D
+ : B
+{
+ explicit D(int i) : B(i) {}
+};
+
+
+int main()
+{
+ {
+ typedef std::pair<int, std::unique_ptr<D>> T0;
+ typedef std::tuple<alloc_first, std::unique_ptr<B>> T1;
+ T0 t0(2, std::unique_ptr<D>(new D(3)));
+ alloc_first::allocator_constructed = false;
+ T1 t1(std::allocator_arg, A1<int>(5), std::move(t0));
+ assert(alloc_first::allocator_constructed);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1)->id_ == 3);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp
new file mode 100644
index 00000000000..93f28d5e6d7
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// explicit tuple(const T&...);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ std::tuple<int> t = 2;
+ assert(std::get<0>(t) == 2);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp
new file mode 100644
index 00000000000..b2a945db21f
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// explicit tuple(const T&...);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ std::tuple<int> t(2);
+ assert(std::get<0>(t) == 2);
+ }
+ {
+ std::tuple<int, char*> t(2, 0);
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == nullptr);
+ }
+ {
+ std::tuple<int, char*> t(2, nullptr);
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == nullptr);
+ }
+ {
+ std::tuple<int, char*, std::string> t(2, nullptr, "text");
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == nullptr);
+ assert(std::get<2>(t) == "text");
+ }
+ // extensions
+ {
+ std::tuple<int, char*, std::string> t(2);
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == nullptr);
+ assert(std::get<2>(t) == "");
+ }
+ {
+ std::tuple<int, char*, std::string> t(2, nullptr);
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == nullptr);
+ assert(std::get<2>(t) == "");
+ }
+ {
+ std::tuple<int, char*, std::string, double> t(2, nullptr, "text");
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == nullptr);
+ assert(std::get<2>(t) == "text");
+ assert(std::get<3>(t) == 0.0);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp
new file mode 100644
index 00000000000..864896e0b21
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_Types2.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// explicit tuple(const T&...);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ std::tuple<int, char*, std::string, double&> t(2, nullptr, "text");
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
new file mode 100644
index 00000000000..91b14f5c7be
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2> tuple(const pair<U1, U2>& u);
+
+#include <tuple>
+#include <utility>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<double, char> T0;
+ typedef std::tuple<int, short> T1;
+ T0 t0(2.5, 'a');
+ T1 t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == short('a'));
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
new file mode 100644
index 00000000000..4672b9eb24b
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes> tuple(const tuple<UTypes...>& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+struct B
+{
+ int id_;
+
+ explicit B(int i) : id_(i) {}
+};
+
+struct D
+ : B
+{
+ explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+ {
+ typedef std::tuple<double> T0;
+ typedef std::tuple<int> T1;
+ T0 t0(2.5);
+ T1 t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ }
+ {
+ typedef std::tuple<double, char> T0;
+ typedef std::tuple<int, int> T1;
+ T0 t0(2.5, 'a');
+ T1 t1 = t0;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ }
+ {
+ typedef std::tuple<double, char, D> T0;
+ typedef std::tuple<int, int, B> T1;
+ T0 t0(2.5, 'a', D(3));
+ 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);
+ typedef std::tuple<double, char, D&> T0;
+ typedef std::tuple<int, int, B&> T1;
+ T0 t0(2.5, 'a', d);
+ T1 t1 = t0;
+ d.id_ = 2;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ assert(std::get<2>(t1).id_ == 2);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp
new file mode 100644
index 00000000000..4ab026d8faa
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/convert_move.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... UTypes> tuple(tuple<UTypes...>&& u);
+
+#include <tuple>
+#include <string>
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ int id_;
+
+ explicit B(int i) : id_(i) {}
+
+ virtual ~B() {}
+};
+
+struct D
+ : B
+{
+ explicit D(int i) : B(i) {}
+};
+
+int main()
+{
+ {
+ typedef std::tuple<double> T0;
+ typedef std::tuple<int> T1;
+ T0 t0(2.5);
+ T1 t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ }
+ {
+ typedef std::tuple<double, char> T0;
+ typedef std::tuple<int, int> T1;
+ T0 t0(2.5, 'a');
+ T1 t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ }
+ {
+ typedef std::tuple<double, char, D> T0;
+ typedef std::tuple<int, int, B> T1;
+ T0 t0(2.5, 'a', D(3));
+ 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);
+ typedef std::tuple<double, char, D&> T0;
+ typedef std::tuple<int, int, B&> T1;
+ T0 t0(2.5, 'a', d);
+ T1 t1 = std::move(t0);
+ d.id_ = 2;
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1) == int('a'));
+ assert(std::get<2>(t1).id_ == 2);
+ }
+ {
+ typedef std::tuple<double, char, std::unique_ptr<D>> T0;
+ typedef std::tuple<int, int, std::unique_ptr<B>> T1;
+ T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3)));
+ 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);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp
new file mode 100644
index 00000000000..6aff2270d2b
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.fail.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple(const tuple& u) = default;
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+ {
+ typedef std::tuple<MoveOnly> T;
+ T t0(MoveOnly(2));
+ T t = t0;
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp
new file mode 100644
index 00000000000..1c637f354d6
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/copy.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple(const tuple& u) = default;
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ T t0;
+ T t = t0;
+ }
+ {
+ typedef std::tuple<int> T;
+ T t0(2);
+ T t = t0;
+ assert(std::get<0>(t) == 2);
+ }
+ {
+ typedef std::tuple<int, char> T;
+ T t0(2, 'a');
+ T t = t0;
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == 'a');
+ }
+ {
+ typedef std::tuple<int, char, std::string> T;
+ T t0(2, 'a', "some text");
+ T t = t0;
+ assert(std::get<0>(t) == 2);
+ assert(std::get<1>(t) == 'a');
+ assert(std::get<2>(t) == "some text");
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
new file mode 100644
index 00000000000..0321fc13a7b
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/default.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// constexpr tuple();
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+#include "../DefaultOnly.h"
+
+int main()
+{
+ {
+ std::tuple<> t;
+ }
+ {
+ std::tuple<int> t;
+ assert(std::get<0>(t) == 0);
+ }
+ {
+ std::tuple<int, char*> t;
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == nullptr);
+ }
+ {
+ std::tuple<int, char*, std::string> t;
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == nullptr);
+ assert(std::get<2>(t) == "");
+ }
+ {
+ std::tuple<int, char*, std::string, DefaultOnly> t;
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == nullptr);
+ assert(std::get<2>(t) == "");
+ assert(std::get<3>(t) == DefaultOnly());
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp
new file mode 100644
index 00000000000..dd4867b18f3
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/move.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// tuple(tuple&& u);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ T t0;
+ T t = std::move(t0);
+ }
+ {
+ typedef std::tuple<MoveOnly> T;
+ T t0(MoveOnly(0));
+ 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 = 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 = std::move(t0);
+ assert(std::get<0>(t) == 0);
+ assert(std::get<1>(t) == 1);
+ assert(std::get<2>(t) == 2);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp
new file mode 100644
index 00000000000..c6f8e710965
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.cnstr/move_pair.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class U1, class U2> tuple(pair<U1, U2>&& u);
+
+#include <tuple>
+#include <utility>
+#include <memory>
+#include <cassert>
+
+struct B
+{
+ int id_;
+
+ explicit B(int i) : id_(i) {}
+
+ virtual ~B() {}
+};
+
+struct D
+ : B
+{
+ explicit D(int i) : B(i) {}
+};
+
+
+int main()
+{
+ {
+ typedef std::pair<double, std::unique_ptr<D>> T0;
+ typedef std::tuple<int, std::unique_ptr<B>> T1;
+ T0 t0(2.5, std::unique_ptr<D>(new D(3)));
+ T1 t1 = std::move(t0);
+ assert(std::get<0>(t1) == 2);
+ assert(std::get<1>(t1)->id_ == 3);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp
new file mode 100644
index 00000000000..86fa52f4569
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/make_tuple.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... Types>
+// tuple<VTypes...> make_tuple(Types&&... t);
+
+#include <tuple>
+#include <functional>
+#include <cassert>
+
+int main()
+{
+ {
+ int i = 0;
+ float j = 0;
+ std::tuple<int, int&, float&> t = std::make_tuple(1, std::ref(i),
+ std::ref(j));
+ assert(std::get<0>(t) == 1);
+ assert(std::get<1>(t) == 0);
+ assert(std::get<2>(t) == 0);
+ i = 2;
+ j = 3.5;
+ assert(std::get<0>(t) == 1);
+ assert(std::get<1>(t) == 2);
+ assert(std::get<2>(t) == 3.5);
+ std::get<1>(t) = 0;
+ std::get<2>(t) = 0;
+ assert(i == 0);
+ assert(j == 0);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp
new file mode 100644
index 00000000000..a232c9a2e0d
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/tie.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... Types>
+// tuple<Types&...> tie(Types&... t);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ int i = 0;
+ std::string s;
+ std::tie(i, std::ignore, s) = std::make_tuple(42, 3.14, "C++");
+ assert(i == 42);
+ assert(s == "C++");
+ }
+}
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
new file mode 100644
index 00000000000..27e25d22def
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.creation/tuple_cat.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// 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);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+ {
+ std::tuple<> t1;
+ std::tuple<> t2;
+ std::tuple<> t3 = std::tuple_cat(t1, t2);
+ }
+ {
+ std::tuple<> t1;
+ std::tuple<int> t2(2);
+ std::tuple<int> t3 = std::tuple_cat(t1, t2);
+ assert(std::get<0>(t3) == 2);
+ }
+ {
+ std::tuple<> t1;
+ std::tuple<int> t2(2);
+ std::tuple<int> t3 = std::tuple_cat(t2, t1);
+ assert(std::get<0>(t3) == 2);
+ }
+ {
+ std::tuple<int*> t1;
+ std::tuple<int> t2(2);
+ std::tuple<int*, int> t3 = std::tuple_cat(t1, t2);
+ assert(std::get<0>(t3) == nullptr);
+ assert(std::get<1>(t3) == 2);
+ }
+ {
+ std::tuple<int*> t1;
+ std::tuple<int> t2(2);
+ std::tuple<int, int*> t3 = std::tuple_cat(t2, t1);
+ assert(std::get<0>(t3) == 2);
+ assert(std::get<1>(t3) == nullptr);
+ }
+ {
+ std::tuple<int*> t1;
+ std::tuple<int, double> t2(2, 3.5);
+ std::tuple<int*, int, double> t3 = std::tuple_cat(t1, t2);
+ assert(std::get<0>(t3) == nullptr);
+ assert(std::get<1>(t3) == 2);
+ assert(std::get<2>(t3) == 3.5);
+ }
+ {
+ std::tuple<int*> t1;
+ std::tuple<int, double> t2(2, 3.5);
+ std::tuple<int, double, int*> t3 = std::tuple_cat(t2, t1);
+ assert(std::get<0>(t3) == 2);
+ assert(std::get<1>(t3) == 3.5);
+ assert(std::get<2>(t3) == nullptr);
+ }
+ {
+ std::tuple<int*, MoveOnly> t1(nullptr, 1);
+ std::tuple<int, double> t2(2, 3.5);
+ std::tuple<int*, MoveOnly, int, double> t3 =
+ std::tuple_cat(std::move(t1), t2);
+ assert(std::get<0>(t3) == nullptr);
+ assert(std::get<1>(t3) == 1);
+ assert(std::get<2>(t3) == 2);
+ assert(std::get<3>(t3) == 3.5);
+ }
+ {
+ std::tuple<int*, MoveOnly> t1(nullptr, 1);
+ std::tuple<int, double> t2(2, 3.5);
+ std::tuple<int, double, int*, MoveOnly> t3 =
+ std::tuple_cat(t2, std::move(t1));
+ assert(std::get<0>(t3) == 2);
+ assert(std::get<1>(t3) == 3.5);
+ assert(std::get<2>(t3) == nullptr);
+ assert(std::get<3>(t3) == 1);
+ }
+ {
+ 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));
+ assert(std::get<0>(t3) == 1);
+ assert(std::get<1>(t3) == 2);
+ assert(std::get<2>(t3) == nullptr);
+ assert(std::get<3>(t3) == 4);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp
new file mode 100644
index 00000000000..d32fbde53ae
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.fail.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+// typename tuple_element<I, tuple<Types...> >::type const&
+// get(const tuple<Types...>& t);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::tuple<double&, std::string, int> T;
+ double d = 1.5;
+ const T t(d, "high", 5);
+ assert(std::get<0>(t) == 1.5);
+ assert(std::get<1>(t) == "high");
+ assert(std::get<2>(t) == 5);
+ std::get<0>(t) = 2.5;
+ assert(std::get<0>(t) == 2.5);
+ assert(std::get<1>(t) == "high");
+ assert(std::get<2>(t) == 5);
+ assert(d == 2.5);
+
+ std::get<1>(t) = "four";
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp
new file mode 100644
index 00000000000..2746f820893
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_const.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+// typename tuple_element<I, tuple<Types...> >::type const&
+// get(const tuple<Types...>& t);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::tuple<int> T;
+ const T t(3);
+ assert(std::get<0>(t) == 3);
+ }
+ {
+ typedef std::tuple<std::string, int> T;
+ const T t("high", 5);
+ assert(std::get<0>(t) == "high");
+ assert(std::get<1>(t) == 5);
+ }
+ {
+ typedef std::tuple<double&, std::string, int> T;
+ double d = 1.5;
+ const T t(d, "high", 5);
+ assert(std::get<0>(t) == 1.5);
+ assert(std::get<1>(t) == "high");
+ assert(std::get<2>(t) == 5);
+ std::get<0>(t) = 2.5;
+ assert(std::get<0>(t) == 2.5);
+ assert(std::get<1>(t) == "high");
+ assert(std::get<2>(t) == 5);
+ assert(d == 2.5);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp
new file mode 100644
index 00000000000..dc9d1ee70c0
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.elem/get_non_const.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+// typename tuple_element<I, tuple<Types...> >::type&
+// get(tuple<Types...>& t);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::tuple<int> T;
+ T t(3);
+ assert(std::get<0>(t) == 3);
+ std::get<0>(t) = 2;
+ assert(std::get<0>(t) == 2);
+ }
+ {
+ typedef std::tuple<std::string, int> T;
+ T t("high", 5);
+ assert(std::get<0>(t) == "high");
+ assert(std::get<1>(t) == 5);
+ std::get<0>(t) = "four";
+ std::get<1>(t) = 4;
+ assert(std::get<0>(t) == "four");
+ assert(std::get<1>(t) == 4);
+ }
+ {
+ typedef std::tuple<double&, std::string, int> T;
+ double d = 1.5;
+ T t(d, "high", 5);
+ assert(std::get<0>(t) == 1.5);
+ assert(std::get<1>(t) == "high");
+ assert(std::get<2>(t) == 5);
+ std::get<0>(t) = 2.5;
+ std::get<1>(t) = "four";
+ std::get<2>(t) = 4;
+ assert(std::get<0>(t) == 2.5);
+ assert(std::get<1>(t) == "four");
+ assert(std::get<2>(t) == 4);
+ assert(d == 2.5);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp
new file mode 100644
index 00000000000..e446e8c3ffb
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <size_t I, class... Types>
+// class tuple_element<I, tuple<Types...> >
+// {
+// public:
+// typedef Ti type;
+// };
+
+#include <tuple>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::tuple<int> T;
+ static_assert((std::is_same<std::tuple_element<0, T>::type,
+ int>::value), "");
+ }
+ {
+ typedef std::tuple<char, int> T;
+ static_assert((std::is_same<std::tuple_element<0, T>::type,
+ char>::value), "");
+ static_assert((std::is_same<std::tuple_element<1, T>::type,
+ int>::value), "");
+ }
+ {
+ typedef std::tuple<int*, char, int> T;
+ static_assert((std::is_same<std::tuple_element<0, T>::type,
+ int*>::value), "");
+ static_assert((std::is_same<std::tuple_element<1, T>::type,
+ char>::value), "");
+ static_assert((std::is_same<std::tuple_element<2, T>::type,
+ int>::value), "");
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp
new file mode 100644
index 00000000000..3020b99706d
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Types>
+// class tuple_size<tuple<Types...>>
+// : public integral_constant<size_t, sizeof...(Types)> { };
+
+#include <tuple>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, 0>,
+ std::tuple_size<T> >::value), "");
+ }
+ {
+ typedef std::tuple<int> T;
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, 1>,
+ std::tuple_size<T> >::value), "");
+ }
+ {
+ typedef std::tuple<char, int> T;
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, 2>,
+ std::tuple_size<T> >::value), "");
+ }
+ {
+ typedef std::tuple<char, char*, int> T;
+ static_assert((std::is_base_of<std::integral_constant<std::size_t, 3>,
+ std::tuple_size<T> >::value), "");
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.range/begin.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.range/begin.pass.cpp
new file mode 100644
index 00000000000..9bab42e3241
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.range/begin.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class InputIterator>
+// InputIterator begin(const tuple<InputIterator, InputIterator>& t);
+
+// template <class InputIterator>
+// InputIterator end(const tuple<InputIterator, InputIterator>& t);
+
+#include <tuple>
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::tuple<int*, int*> T;
+ int array[5] = {0, 1, 2, 3, 4};
+ const T t(std::begin(array), std::end(array));
+ assert(begin(t) == std::begin(array));
+ assert(end(t) == std::end(array));
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
new file mode 100644
index 00000000000..4fb08df30e6
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.rel/eq.pass.cpp
@@ -0,0 +1,144 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... TTypes, class... UTypes>
+// bool
+// operator==(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::tuple<> T1;
+ typedef std::tuple<> T2;
+ const T1 t1;
+ const T2 t2;
+ assert(t1 == t2);
+ assert(!(t1 != t2));
+ }
+ {
+ typedef std::tuple<int> T1;
+ typedef std::tuple<double> T2;
+ const T1 t1(1);
+ const T2 t2(1.1);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<int> T1;
+ typedef std::tuple<double> T2;
+ const T1 t1(1);
+ const T2 t2(1);
+ assert(t1 == t2);
+ assert(!(t1 != t2));
+ }
+ {
+ typedef std::tuple<int, double> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1, char(2));
+ assert(t1 == t2);
+ assert(!(t1 != t2));
+ }
+ {
+ typedef std::tuple<int, double> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1, char(3));
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<int, double> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1.1, char(2));
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<int, double> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1.1, char(3));
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 2, 3);
+ assert(t1 == t2);
+ assert(!(t1 != t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1.1, 2, 3);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 3, 3);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 2, 4);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 3, 2);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1.1, 2, 2);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1.1, 3, 3);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1.1, 3, 2);
+ assert(!(t1 == t2));
+ assert(t1 != t2);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp
new file mode 100644
index 00000000000..4ebaf6f162d
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.rel/lt.pass.cpp
@@ -0,0 +1,196 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template<class... TTypes, class... UTypes>
+// bool
+// operator<(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+//
+// template<class... TTypes, class... UTypes>
+// bool
+// operator>(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+//
+// template<class... TTypes, class... UTypes>
+// bool
+// operator<=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+//
+// template<class... TTypes, class... UTypes>
+// bool
+// operator>=(const tuple<TTypes...>& t, const tuple<UTypes...>& u);
+
+#include <tuple>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::tuple<> T1;
+ typedef std::tuple<> T2;
+ const T1 t1;
+ const T2 t2;
+ assert(!(t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char> T1;
+ typedef std::tuple<double> T2;
+ const T1 t1(1);
+ const T2 t2(1);
+ assert(!(t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char> T1;
+ typedef std::tuple<double> T2;
+ const T1 t1(1);
+ const T2 t2(0.9);
+ assert(!(t1 < t2));
+ assert(!(t1 <= t2));
+ assert( (t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char> T1;
+ typedef std::tuple<double> T2;
+ const T1 t1(1);
+ const T2 t2(1.1);
+ assert( (t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert(!(t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1, 2);
+ assert(!(t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(0.9, 2);
+ assert(!(t1 < t2));
+ assert(!(t1 <= t2));
+ assert( (t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1.1, 2);
+ assert( (t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert(!(t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1, 1);
+ assert(!(t1 < t2));
+ assert(!(t1 <= t2));
+ assert( (t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int> T1;
+ typedef std::tuple<double, char> T2;
+ const T1 t1(1, 2);
+ const T2 t2(1, 3);
+ assert( (t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert(!(t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 2, 3);
+ assert(!(t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(0.9, 2, 3);
+ assert(!(t1 < t2));
+ assert(!(t1 <= t2));
+ assert( (t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1.1, 2, 3);
+ assert( (t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert(!(t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 1, 3);
+ assert(!(t1 < t2));
+ assert(!(t1 <= t2));
+ assert( (t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 3, 3);
+ assert( (t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert(!(t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 2, 2);
+ assert(!(t1 < t2));
+ assert(!(t1 <= t2));
+ assert( (t1 > t2));
+ assert( (t1 >= t2));
+ }
+ {
+ typedef std::tuple<char, int, double> T1;
+ typedef std::tuple<double, char, int> T2;
+ const T1 t1(1, 2, 3);
+ const T2 t2(1, 2, 4);
+ assert( (t1 < t2));
+ assert( (t1 <= t2));
+ assert(!(t1 > t2));
+ assert(!(t1 >= t2));
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp
new file mode 100644
index 00000000000..534c6e0d2e5
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.special/non_member_swap.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Types>
+// void swap(tuple<Types...>& x, tuple<Types...>& y);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ T t0;
+ T t1;
+ swap(t0, t1);
+ }
+ {
+ typedef std::tuple<MoveOnly> T;
+ T t0(MoveOnly(0));
+ T t1(MoveOnly(1));
+ swap(t0, t1);
+ assert(std::get<0>(t0) == 1);
+ assert(std::get<0>(t1) == 0);
+ }
+ {
+ typedef std::tuple<MoveOnly, MoveOnly> T;
+ T t0(MoveOnly(0), MoveOnly(1));
+ T t1(MoveOnly(2), MoveOnly(3));
+ swap(t0, t1);
+ assert(std::get<0>(t0) == 2);
+ assert(std::get<1>(t0) == 3);
+ assert(std::get<0>(t1) == 0);
+ assert(std::get<1>(t1) == 1);
+ }
+ {
+ typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
+ T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
+ T t1(MoveOnly(3), MoveOnly(4), MoveOnly(5));
+ swap(t0, t1);
+ assert(std::get<0>(t0) == 3);
+ assert(std::get<1>(t0) == 4);
+ assert(std::get<2>(t0) == 5);
+ assert(std::get<0>(t1) == 0);
+ assert(std::get<1>(t1) == 1);
+ assert(std::get<2>(t1) == 2);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp
new file mode 100644
index 00000000000..64e40957a11
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.swap/member_swap.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// void swap(tuple& rhs);
+
+#include <tuple>
+#include <cassert>
+
+#include "../MoveOnly.h"
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ T t0;
+ T t1;
+ t0.swap(t1);
+ }
+ {
+ typedef std::tuple<MoveOnly> T;
+ T t0(MoveOnly(0));
+ T t1(MoveOnly(1));
+ t0.swap(t1);
+ assert(std::get<0>(t0) == 1);
+ assert(std::get<0>(t1) == 0);
+ }
+ {
+ typedef std::tuple<MoveOnly, MoveOnly> T;
+ T t0(MoveOnly(0), MoveOnly(1));
+ T t1(MoveOnly(2), MoveOnly(3));
+ t0.swap(t1);
+ assert(std::get<0>(t0) == 2);
+ assert(std::get<1>(t0) == 3);
+ assert(std::get<0>(t1) == 0);
+ assert(std::get<1>(t1) == 1);
+ }
+ {
+ typedef std::tuple<MoveOnly, MoveOnly, MoveOnly> T;
+ T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2));
+ T t1(MoveOnly(3), MoveOnly(4), MoveOnly(5));
+ t0.swap(t1);
+ assert(std::get<0>(t0) == 3);
+ assert(std::get<1>(t0) == 4);
+ assert(std::get<2>(t0) == 5);
+ assert(std::get<0>(t1) == 0);
+ assert(std::get<1>(t1) == 1);
+ assert(std::get<2>(t1) == 2);
+ }
+}
diff --git a/libcxx/test/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp b/libcxx/test/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp
new file mode 100644
index 00000000000..80f141fbb23
--- /dev/null
+++ b/libcxx/test/utilities/tuple/tuple.tuple/tuple.traits/uses_allocator.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <tuple>
+
+// template <class... Types> class tuple;
+
+// template <class... Types, class Alloc>
+// struct uses_allocator<tuple<Types...>, Alloc> : true_type { };
+
+#include <tuple>
+#include <type_traits>
+
+struct A {};
+
+int main()
+{
+ {
+ typedef std::tuple<> T;
+ static_assert((std::is_base_of<std::true_type,
+ std::uses_allocator<T, A>>::value), "");
+ }
+ {
+ typedef std::tuple<int> T;
+ static_assert((std::is_base_of<std::true_type,
+ std::uses_allocator<T, A>>::value), "");
+ }
+ {
+ typedef std::tuple<char, int> T;
+ static_assert((std::is_base_of<std::true_type,
+ std::uses_allocator<T, A>>::value), "");
+ }
+ {
+ typedef std::tuple<double&, char, int> T;
+ static_assert((std::is_base_of<std::true_type,
+ std::uses_allocator<T, A>>::value), "");
+ }
+}
OpenPOWER on IntegriCloud