1 // { dg-options "-std=gnu++0x" }
3 // Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
30 // NOTE: This makes use of the fact that we know how moveable
31 // is implemented on tuple. If the implementation changed
32 // this test may begin to fail.
36 #include <testsuite_hooks.h>
40 explicit MoveOnly (int j) : i(j) { }
42 MoveOnly (MoveOnly&& m) : i(m.i) { }
44 MoveOnly& operator=(MoveOnly&& m)
45 { i = m.i; return *this; }
47 MoveOnly(MoveOnly const&) = delete;
48 MoveOnly& operator=(MoveOnly const&) = delete;
50 bool operator==(MoveOnly const& m)
53 void swap(MoveOnly&& m)
54 { std::swap(m.i, i); }
59 void swap(MoveOnly& m1, MoveOnly& m2)
63 make_move_only (int i)
64 { return MoveOnly(i); }
76 bool test __attribute__((unused)) = true;
78 std::tuple<int> t1(1), t2(2);
81 VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 );
86 bool test __attribute__((unused)) = true;
88 std::tuple<int, float> t1(1, 1.0f), t2(2, 2.0f);
91 VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 );
92 VERIFY( std::get<1>(t1) == 2.0f && std::get<1>(t2) == 1.0f );
97 bool test __attribute__((unused)) = true;
99 std::tuple<int, float, MoveOnly>
100 t1(1, 1.0f, make_move_only(1)),
101 t2(2, 2.0f, make_move_only(2));
105 VERIFY( std::get<0>(t1) == 2 && std::get<0>(t2) == 1 );
106 VERIFY( std::get<1>(t1) == 2.0f && std::get<1>(t2) == 1.0f );
107 VERIFY( std::get<2>(t1) == make_move_only(2)
108 && std::get<2>(t2) == make_move_only(1) );