summaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/20_util/pair
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/testsuite/20_util/pair')
-rw-r--r--libstdc++-v3/testsuite/20_util/pair/1.cc78
-rw-r--r--libstdc++-v3/testsuite/20_util/pair/2.cc59
-rw-r--r--libstdc++-v3/testsuite/20_util/pair/3.cc78
-rw-r--r--libstdc++-v3/testsuite/20_util/pair/4.cc66
-rw-r--r--libstdc++-v3/testsuite/20_util/pair/40925.cc67
-rw-r--r--libstdc++-v3/testsuite/20_util/pair/44487.cc51
-rw-r--r--libstdc++-v3/testsuite/20_util/pair/comparison_operators/constexpr.cc29
-rw-r--r--libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc39
-rw-r--r--libstdc++-v3/testsuite/20_util/pair/moveable.cc63
-rw-r--r--libstdc++-v3/testsuite/20_util/pair/piecewise.cc98
-rw-r--r--libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc52
-rw-r--r--libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc25
-rw-r--r--libstdc++-v3/testsuite/20_util/pair/swap.cc50
13 files changed, 755 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/20_util/pair/1.cc b/libstdc++-v3/testsuite/20_util/pair/1.cc
new file mode 100644
index 000000000..f5b15f755
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/1.cc
@@ -0,0 +1,78 @@
+// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2004, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.2.2 Pairs
+
+#include <utility>
+#include <testsuite_hooks.h>
+
+class gnu_obj
+{
+ int i;
+public:
+ gnu_obj(int arg = 0): i(arg) { }
+ bool operator==(const gnu_obj& rhs) const { return i == rhs.i; }
+ bool operator<(const gnu_obj& rhs) const { return i < rhs.i; }
+};
+
+template<typename T>
+ struct gnu_t
+ {
+ bool b;
+ public:
+ gnu_t(bool arg = 0): b(arg) { }
+ bool operator==(const gnu_t& rhs) const { return b == rhs.b; }
+ bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); }
+ };
+
+
+// heterogeneous
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::pair<bool, long> p_bl_1(true, 433);
+ std::pair<bool, long> p_bl_2 = std::make_pair(true, 433);
+ VERIFY( p_bl_1 == p_bl_2 );
+ VERIFY( !(p_bl_1 < p_bl_2) );
+
+ std::pair<const char*, float> p_sf_1("total enlightenment", 433.00);
+ std::pair<const char*, float> p_sf_2 = std::make_pair("total enlightenment",
+ 433.00);
+ VERIFY( p_sf_1 == p_sf_2 );
+ VERIFY( !(p_sf_1 < p_sf_2) );
+
+ std::pair<const char*, gnu_obj> p_sg_1("enlightenment", gnu_obj(5));
+ std::pair<const char*, gnu_obj> p_sg_2 = std::make_pair("enlightenment",
+ gnu_obj(5));
+ VERIFY( p_sg_1 == p_sg_2 );
+ VERIFY( !(p_sg_1 < p_sg_2) );
+
+ std::pair<gnu_t<long>, gnu_obj> p_st_1(gnu_t<long>(false), gnu_obj(5));
+ std::pair<gnu_t<long>, gnu_obj> p_st_2 = std::make_pair(gnu_t<long>(false),
+ gnu_obj(5));
+ VERIFY( p_st_1 == p_st_2 );
+ VERIFY( !(p_st_1 < p_st_2) );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/pair/2.cc b/libstdc++-v3/testsuite/20_util/pair/2.cc
new file mode 100644
index 000000000..0826cdb2f
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/2.cc
@@ -0,0 +1,59 @@
+// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2004, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.2.2 Pairs
+
+#include <utility>
+#include <testsuite_hooks.h>
+
+class gnu_obj
+{
+ int i;
+public:
+ gnu_obj(int arg = 0): i(arg) { }
+ bool operator==(const gnu_obj& rhs) const { return i == rhs.i; }
+ bool operator<(const gnu_obj& rhs) const { return i < rhs.i; }
+};
+
+template<typename T>
+ struct gnu_t
+ {
+ bool b;
+ public:
+ gnu_t(bool arg = 0): b(arg) { }
+ bool operator==(const gnu_t& rhs) const { return b == rhs.b; }
+ bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); }
+ };
+
+// homogeneous
+void test02()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::pair<bool, bool> p_bb_1(true, false);
+ std::pair<bool, bool> p_bb_2 = std::make_pair(true, false);
+ VERIFY( p_bb_1 == p_bb_2 );
+ VERIFY( !(p_bb_1 < p_bb_2) );
+}
+
+int main()
+{
+ test02();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/pair/3.cc b/libstdc++-v3/testsuite/20_util/pair/3.cc
new file mode 100644
index 000000000..fc19a4acd
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/3.cc
@@ -0,0 +1,78 @@
+// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2004, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.2.2 Pairs
+
+#include <utility>
+#include <testsuite_hooks.h>
+
+class gnu_obj
+{
+ int i;
+public:
+ gnu_obj(int arg = 0): i(arg) { }
+ bool operator==(const gnu_obj& rhs) const { return i == rhs.i; }
+ bool operator<(const gnu_obj& rhs) const { return i < rhs.i; }
+};
+
+template<typename T>
+ struct gnu_t
+ {
+ bool b;
+ public:
+ gnu_t(bool arg = 0): b(arg) { }
+ bool operator==(const gnu_t& rhs) const { return b == rhs.b; }
+ bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); }
+ };
+
+
+// const
+void test03()
+{
+ bool test __attribute__((unused)) = true;
+
+ const std::pair<bool, long> p_bl_1(true, 433);
+ const std::pair<bool, long> p_bl_2 = std::make_pair(true, 433);
+ VERIFY( p_bl_1 == p_bl_2 );
+ VERIFY( !(p_bl_1 < p_bl_2) );
+
+ const std::pair<const char*, float> p_sf_1("total enlightenment", 433.00);
+ const std::pair<const char*, float> p_sf_2 =
+ std::make_pair("total enlightenment", 433.00);
+ VERIFY( p_sf_1 == p_sf_2 );
+ VERIFY( !(p_sf_1 < p_sf_2) );
+
+ const std::pair<const char*, gnu_obj> p_sg_1("enlightenment", gnu_obj(5));
+ const std::pair<const char*, gnu_obj> p_sg_2 =
+ std::make_pair("enlightenment", gnu_obj(5));
+ VERIFY( p_sg_1 == p_sg_2 );
+ VERIFY( !(p_sg_1 < p_sg_2) );
+
+ const std::pair<gnu_t<long>, gnu_obj> p_st_1(gnu_t<long>(false), gnu_obj(5));
+ const std::pair<gnu_t<long>, gnu_obj> p_st_2 =
+ std::make_pair(gnu_t<long>(false), gnu_obj(5));
+ VERIFY( p_st_1 == p_st_2 );
+ VERIFY( !(p_st_1 < p_st_2) );
+}
+
+int main()
+{
+ test03();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/pair/4.cc b/libstdc++-v3/testsuite/20_util/pair/4.cc
new file mode 100644
index 000000000..7431fc1e7
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/4.cc
@@ -0,0 +1,66 @@
+// 2001-06-18 Benjamin Kosnik <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2004, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// 20.2.2 Pairs
+
+#include <utility>
+#include <testsuite_hooks.h>
+
+class gnu_obj
+{
+ int i;
+public:
+ gnu_obj(int arg = 0): i(arg) { }
+ bool operator==(const gnu_obj& rhs) const { return i == rhs.i; }
+ bool operator<(const gnu_obj& rhs) const { return i < rhs.i; }
+};
+
+template<typename T>
+ struct gnu_t
+ {
+ bool b;
+ public:
+ gnu_t(bool arg = 0): b(arg) { }
+ bool operator==(const gnu_t& rhs) const { return b == rhs.b; }
+ bool operator<(const gnu_t& rhs) const { return int(b) < int(rhs.b); }
+ };
+
+// const&
+void test04()
+{
+ bool test __attribute__((unused)) = true;
+ const gnu_obj& obj1 = gnu_obj(5);
+ const std::pair<const char*, gnu_obj> p_sg_1("enlightenment", obj1);
+ const std::pair<const char*, gnu_obj> p_sg_2 =
+ std::make_pair("enlightenment", obj1);
+ VERIFY( p_sg_1 == p_sg_2 );
+ VERIFY( !(p_sg_1 < p_sg_2) );
+
+ const gnu_t<long>& tmpl1 = gnu_t<long>(false);
+ const std::pair<gnu_t<long>, gnu_obj> p_st_1(tmpl1, obj1);
+ const std::pair<gnu_t<long>, gnu_obj> p_st_2 = std::make_pair(tmpl1, obj1);
+ VERIFY( p_st_1 == p_st_2 );
+ VERIFY( !(p_st_1 < p_st_2) );
+}
+
+int main()
+{
+ test04();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/pair/40925.cc b/libstdc++-v3/testsuite/20_util/pair/40925.cc
new file mode 100644
index 000000000..6abeb617f
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/40925.cc
@@ -0,0 +1,67 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <utility>
+
+struct X
+{
+ explicit X(int, int) { }
+
+private:
+ X(const X&) = delete;
+};
+
+struct move_only
+{
+ move_only() { }
+ move_only(move_only&&) { }
+
+private:
+ move_only(const move_only&) = delete;
+};
+
+// libstdc++/40925
+void test01()
+{
+ int *ip = 0;
+ int X::*mp = 0;
+
+ std::pair<int*, int*> p1(0, 0);
+ std::pair<int*, int*> p2(ip, 0);
+ std::pair<int*, int*> p3(0, ip);
+ std::pair<int*, int*> p4(ip, ip);
+
+ std::pair<int X::*, int*> p5(0, 0);
+ std::pair<int X::*, int X::*> p6(mp, 0);
+ std::pair<int X::*, int X::*> p7(0, mp);
+ std::pair<int X::*, int X::*> p8(mp, mp);
+
+ std::pair<int*, move_only> p9(0, move_only());
+ std::pair<int X::*, move_only> p10(0, move_only());
+ std::pair<move_only, int*> p11(move_only(), 0);
+ std::pair<move_only, int X::*> p12(move_only(), 0);
+
+ std::pair<int*, move_only> p13(ip, move_only());
+ std::pair<int X::*, move_only> p14(mp, move_only());
+ std::pair<move_only, int*> p15(move_only(), ip);
+ std::pair<move_only, int X::*> p16(move_only(), mp);
+
+ std::pair<move_only, move_only> p17(move_only(), move_only());
+}
diff --git a/libstdc++-v3/testsuite/20_util/pair/44487.cc b/libstdc++-v3/testsuite/20_util/pair/44487.cc
new file mode 100644
index 000000000..833d98645
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/44487.cc
@@ -0,0 +1,51 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <utility>
+
+int x, y;
+
+std::pair<int&, int&>
+foo1()
+{
+ std::pair<int&, int&> blah(x, y);
+ return blah;
+}
+
+std::pair<int&, int&>
+foo2()
+{
+ const std::pair<int&, int&> blah(x, y);
+ return blah;
+}
+
+std::pair<int&, int&>
+foo3()
+{
+ std::pair<int&, int&> blah(x, y);
+ return std::pair<int&, int&>(std::move(blah));
+}
+
+std::pair<int&, int&>
+foo4()
+{
+ const std::pair<int&, int&> blah(x, y);
+ return std::pair<int&, int&>(std::move(blah));
+}
diff --git a/libstdc++-v3/testsuite/20_util/pair/comparison_operators/constexpr.cc b/libstdc++-v3/testsuite/20_util/pair/comparison_operators/constexpr.cc
new file mode 100644
index 000000000..d5dc6e4e1
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/comparison_operators/constexpr.cc
@@ -0,0 +1,29 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <utility>
+#include <testsuite_common_types.h>
+
+int main()
+{
+ __gnu_test::constexpr_comparison_operators test;
+ test.operator()<std::pair<int, int>>();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc b/libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc
new file mode 100644
index 000000000..1c854627e
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/cons/constexpr.cc
@@ -0,0 +1,39 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <testsuite_common_types.h>
+
+int main()
+{
+ __gnu_test::constexpr_default_constructible test1;
+ test1.operator()<std::pair<int, int>>();
+
+ __gnu_test::constexpr_single_value_constructible test2;
+ test2.operator()<std::pair<int, int>, std::pair<int, int>>();
+ test2.operator()<std::pair<int, int>, std::pair<short, short>>();
+
+ // test 3
+ const int i1(129);
+ const int i2(6);
+ constexpr std::pair<int, int> p3(i1, i2);
+
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/pair/moveable.cc b/libstdc++-v3/testsuite/20_util/pair/moveable.cc
new file mode 100644
index 000000000..9abdd8107
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/moveable.cc
@@ -0,0 +1,63 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// NOTE: This makes use of the fact that we know how moveable
+// is implemented on pair, and also vector. If the implementation
+// changes this test may begin to fail.
+
+#include <vector>
+#include <utility>
+#include <testsuite_hooks.h>
+
+bool test __attribute__((unused)) = true;
+
+void
+test1()
+{
+ std::pair<int,int> a(1,1),b(2,2);
+ a=std::move(b);
+ VERIFY(a.first == 2 && a.second == 2 && b.first == 2 && b.second == 2);
+ std::pair<int,int> c(std::move(a));
+ VERIFY(c.first == 2 && c.second == 2 && a.first == 2 && a.second == 2);
+}
+
+void
+test2()
+{
+ std::vector<int> v,w;
+ v.push_back(1);
+ w.push_back(2);
+ w.push_back(2);
+ std::pair<int, std::vector<int> > p = make_pair(1,v);
+ std::pair<int, std::vector<int> > q = make_pair(2,w);
+ p = std::move(q);
+ VERIFY(p.first == 2 && q.first == 2 &&
+ p.second.size() == 2 && q.second.size() == 0);
+ std::pair<int, std::vector<int> > r(std::move(p));
+ VERIFY(r.first == 2 && p.first == 2 &&
+ r.second.size() == 2 && p.second.size() == 0);
+}
+
+int
+main()
+{
+ test1();
+ test2();
+}
diff --git a/libstdc++-v3/testsuite/20_util/pair/piecewise.cc b/libstdc++-v3/testsuite/20_util/pair/piecewise.cc
new file mode 100644
index 000000000..ef7147320
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/piecewise.cc
@@ -0,0 +1,98 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-04-30 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// Tuple
+
+#include <utility>
+#include <tuple>
+#include <testsuite_hooks.h>
+
+struct type_zero
+{
+ type_zero() : n_(757) { }
+
+ type_zero(const type_zero&) = delete;
+ type_zero(type_zero&& other) : n_(other.n_) { }
+
+ int get() const { return n_; }
+
+private:
+ int n_;
+};
+
+struct type_one
+{
+ type_one(int n) : n_(n) { }
+
+ type_one(const type_one&) = delete;
+ type_one(type_one&& other) : n_(other.n_) { }
+
+ int get() const { return n_; }
+
+private:
+ int n_;
+};
+
+struct type_two
+{
+ type_two(int n1, int n2) : n1_(n1), n2_(n2) { }
+
+ type_two(const type_two&) = delete;
+ type_two(type_two&& other) : n1_(other.n1_), n2_(other.n2_) { }
+
+ int get1() const { return n1_; }
+ int get2() const { return n2_; }
+
+private:
+ int n1_, n2_;
+};
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::pair<type_one, type_zero> pp0(std::piecewise_construct_t(),
+ std::forward_as_tuple(-3),
+ std::forward_as_tuple());
+ VERIFY( pp0.first.get() == -3 );
+ VERIFY( pp0.second.get() == 757 );
+
+ std::pair<type_one, type_two> pp1(std::piecewise_construct_t(),
+ std::forward_as_tuple(6),
+ std::forward_as_tuple(5, 4));
+ VERIFY( pp1.first.get() == 6 );
+ VERIFY( pp1.second.get1() == 5 );
+ VERIFY( pp1.second.get2() == 4 );
+
+ std::pair<type_two, type_two> pp2(std::piecewise_construct_t(),
+ std::forward_as_tuple(2, 1),
+ std::forward_as_tuple(-1, -3));
+ VERIFY( pp2.first.get1() == 2 );
+ VERIFY( pp2.first.get2() == 1 );
+ VERIFY( pp2.second.get1() == -1 );
+ VERIFY( pp2.second.get2() == -3 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc b/libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc
new file mode 100644
index 000000000..36d380dcf
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/requirements/dr801.cc
@@ -0,0 +1,52 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2010 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <memory>
+#include <type_traits>
+
+// DR 801, pair and tuple vs. "passed in registers"
+void test_trivial()
+{
+ // PODType, TType, NType, SLType, LType, NLType, LTypeDerived
+ typedef std::pair<int, int> pair_type;
+ // static_assert(std::is_literal_type<pair_type>::value, "! literal");
+ static_assert(std::has_trivial_copy_constructor<pair_type>::value,
+ "! triv copy");
+ static_assert(std::has_trivial_destructor<pair_type>::value,
+ "! triv destructor");
+ // static_assert(std::is_standard_layout<pair_type>::value,
+ // "! standard layout");
+
+ // Negative
+ /*
+ static_assert(std::has_trivial_default_constructor<pair_type>::value,
+ "! triv default");
+ static_assert(std::has_trivial_copy_assign<pair_type>::value,
+ "! triv assign");
+ static_assert(std::is_trivial<pair_type>::value, "! triv");
+ static_assert(std::is_pod<pair_type>::value, "! pod");
+ */
+}
+
+int main()
+{
+ test_trivial();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc
new file mode 100644
index 000000000..262c575cf
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/requirements/explicit_instantiation/1.cc
@@ -0,0 +1,25 @@
+// { dg-do compile }
+
+// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+// This file tests explicit instantiation of library containers.
+
+#include <utility>
+
+template class std::pair<int, long>;
diff --git a/libstdc++-v3/testsuite/20_util/pair/swap.cc b/libstdc++-v3/testsuite/20_util/pair/swap.cc
new file mode 100644
index 000000000..a76f5f3cb
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/swap.cc
@@ -0,0 +1,50 @@
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2007, 2009 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+
+#include <utility>
+#include <testsuite_allocator.h>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ typedef __gnu_test::uneq_allocator<double> ua_type;
+ ua_type one(1), two(2);
+
+ std::pair<ua_type, int> p1(one, 1), p2(two, 2);
+
+ p1.swap(p2);
+ VERIFY( p1.first.get_personality() == 2 );
+ VERIFY( p1.second == 2 );
+ VERIFY( p2.first.get_personality() == 1 );
+ VERIFY( p2.second == 1 );
+
+ swap(p1, p2);
+ VERIFY( p2.first.get_personality() == 2 );
+ VERIFY( p2.second == 2 );
+ VERIFY( p1.first.get_personality() == 1 );
+ VERIFY( p1.second == 1 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}