1 // { dg-options "-std=gnu++0x" }
3 // Copyright (C) 2007-2013 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
21 // NOTE: This makes use of the fact that we know how moveable
22 // is implemented on tuple. If the implementation changed
23 // this test may begin to fail.
27 #include <testsuite_hooks.h>
31 explicit MoveOnly (int j) : i(j) { }
33 MoveOnly (MoveOnly&& m) : i(m.i) { }
35 MoveOnly& operator=(MoveOnly&& m)
36 { i = m.i; return *this; }
38 MoveOnly(MoveOnly const&) = delete;
39 MoveOnly& operator=(MoveOnly const&) = delete;
41 bool operator==(MoveOnly const& m)
44 void swap(MoveOnly& m)
45 { std::swap(m.i, i); }
50 void swap(MoveOnly& m1, MoveOnly& m2)
54 make_move_only (int i)
55 { return MoveOnly(i); }
59 bool test __attribute__((unused)) = true;
69 bool test __attribute__((unused)) = true;
71 std::tuple<int> t1(1), t2(2);
74 VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 );
79 bool test __attribute__((unused)) = true;
81 std::tuple<int, float> t1(1, 1.0f), t2(2, 2.0f);
84 VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 );
85 VERIFY( std::get<1>(t1) == 2.0f && std::get<1>(t2) == 1.0f );
90 bool test __attribute__((unused)) = true;
92 std::tuple<int, float, MoveOnly>
93 t1(1, 1.0f, make_move_only(1)),
94 t2(2, 2.0f, make_move_only(2));
98 VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 );
99 VERIFY( std::get<1>(t1) == 2.0f && std::get<1>(t2) == 1.0f );
100 VERIFY( std::get<2>(t1) == make_move_only(2)
101 && std::get<2>(t2) == make_move_only(1) );