1 // { dg-options "-std=gnu++0x" }
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010
4 // Free Software Foundation, Inc.
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 3, or (at your option)
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.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 // 25.3.1 algorithms, sort()
23 #undef _GLIBCXX_CONCEPT_CHECKS
25 // XXX FIXME: parallel-mode should deal correctly with moveable-only types
26 // per C++0x, at minimum smoothly fall back to serial.
27 #undef _GLIBCXX_PARALLEL
30 #include <testsuite_hooks.h>
31 #include <testsuite_iterators.h>
32 #include <testsuite_rvalref.h>
34 using __gnu_test::test_container
;
35 using __gnu_test::random_access_iterator_wrapper
;
36 using __gnu_test::rvalstruct
;
37 using std::partial_sort
;
39 typedef test_container
<rvalstruct
, random_access_iterator_wrapper
> Container
;
41 const int A
[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7,
43 const int N
= sizeof(A
) / sizeof(int);
49 bool test
__attribute__((unused
)) = true;
52 std::copy(A
, A
+ N
, s1
);
53 Container
con(s1
, s1
+ N
);
54 std::sort(con
.begin(), con
.end());
55 VERIFY( s1
[0].valid
);
56 for(int i
= 1; i
< N
; ++i
)
57 VERIFY( s1
[i
].val
>s1
[i
-1].val
&& s1
[i
].valid
);
60 bool order(const rvalstruct
& lhs
, const rvalstruct
& rhs
)
67 bool test
__attribute__((unused
)) = true;
70 std::copy(A
, A
+ N
, s1
);
71 Container
con(s1
, s1
+ N
);
72 std::sort(con
.begin(), con
.end(), order
);
73 VERIFY( s1
[0].valid
);
74 for(int i
= 1; i
< N
; ++i
)
75 VERIFY( s1
[i
].val
>s1
[i
-1].val
&& s1
[i
].valid
);