]>
Commit | Line | Data |
---|---|---|
f5783e34 CJ |
1 | // { dg-require-rvalref "" } |
2 | // { dg-options "-std=gnu++0x" } | |
3 | ||
4 | // Copyright (C) 2005, 2007 Free Software Foundation, Inc. | |
5 | // | |
6 | // This file is part of the GNU ISO C++ Library. This library is free | |
7 | // software; you can redistribute it and/or modify it under the | |
8 | // terms of the GNU General Public License as published by the | |
9 | // Free Software Foundation; either version 2, or (at your option) | |
10 | // any later version. | |
11 | ||
12 | // This library is distributed in the hope that it will be useful, | |
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | // GNU General Public License for more details. | |
16 | ||
17 | // You should have received a copy of the GNU General Public License along | |
18 | // with this library; see the file COPYING. If not, write to the Free | |
19 | // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
20 | // USA. | |
21 | ||
22 | // 25.3.1 algorithms, sort() | |
23 | ||
24 | #undef _GLIBCXX_CONCEPT_CHECKS | |
25 | #define _GLIBCXX_TESTSUITE_ALLOW_RVALREF_ALIASING | |
26 | ||
27 | #include <algorithm> | |
28 | #include <testsuite_hooks.h> | |
29 | #include <testsuite_iterators.h> | |
30 | #include <testsuite_rvalref.h> | |
31 | ||
32 | bool test __attribute__((unused)) = true; | |
33 | ||
34 | using __gnu_test::test_container; | |
35 | using __gnu_test::random_access_iterator_wrapper; | |
36 | using __gnu_test::rvalstruct; | |
37 | using std::partial_sort; | |
38 | ||
39 | typedef test_container<rvalstruct, random_access_iterator_wrapper> Container; | |
40 | ||
41 | ||
42 | const int A[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, | |
43 | 17, 8, 18, 9, 19}; | |
44 | const int N = sizeof(A) / sizeof(int); | |
45 | ||
46 | // 25.3.1.1 sort() | |
47 | void | |
48 | test01() | |
49 | { | |
50 | rvalstruct s1[N]; | |
51 | std::copy(A, A + N, s1); | |
52 | Container con(s1, s1 + N); | |
53 | std::sort(con.begin(), con.end()); | |
54 | VERIFY(s1[0].valid); | |
55 | for(int i = 1; i < N; ++i) | |
56 | VERIFY(s1[i].val>s1[i-1].val && s1[i].valid); | |
57 | } | |
58 | ||
59 | int | |
60 | main() | |
61 | { | |
62 | test01(); | |
63 | return 0; | |
64 | } |