OSDN Git Service

f7a35ffec2cd624386184c029999eec034a164b4
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / 25_algorithms / inplace_merge / moveable.cc
1 // { dg-options "-std=gnu++0x" }
2
3 // Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4 //
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)
9 // any later version.
10
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.
15
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/>.
19
20 // 25.3.4 [lib.alg.merge]
21
22 // XXX FIXME:  parallel-mode should deal correctly with moveable-only types
23 // per C++0x, at minimum smoothly fall back to serial.
24 #undef _GLIBCXX_PARALLEL
25
26 #include <algorithm>
27 #include <testsuite_hooks.h>
28 #include <testsuite_iterators.h>
29 #include <testsuite_rvalref.h>
30
31 using __gnu_test::test_container;
32 using __gnu_test::bidirectional_iterator_wrapper;
33 using __gnu_test::rvalstruct;
34
35 typedef test_container<rvalstruct, bidirectional_iterator_wrapper> container;
36
37 void
38 test01()
39 {
40   bool test __attribute__((unused)) = true;
41
42   int array[]={0,2,4,1,3,5};
43   rvalstruct rv_array[6];
44   std::copy(array, array + 6, rv_array);
45   container con(rv_array, rv_array + 6);
46   std::inplace_merge(con.begin(), con.it(3), con.end());
47   VERIFY( rv_array[0] == 0 && rv_array[1] == 1 && rv_array[2] == 2
48           && rv_array[3] == 3 && rv_array[4] == 4 && rv_array[5] == 5 );
49 }
50
51 int 
52 main()
53 {
54   test01();
55   return 0;
56 }