1 // { dg-do run { target c++11 } }
3 // Copyright (C) 2011-2019 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/>.
20 #undef _GLIBCXX_CONCEPT_CHECKS
23 #include <testsuite_hooks.h>
24 #include <testsuite_iterators.h>
25 #include <testsuite_rvalref.h>
27 using __gnu_test::test_container
;
28 using __gnu_test::random_access_iterator_wrapper
;
30 typedef __gnu_test::rvalstruct_compare_by_value V
;
31 typedef test_container
<V
, random_access_iterator_wrapper
> Container
;
36 V s1
[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7,
38 const int N
= sizeof(s1
) / sizeof(V
);
39 Container
con(s1
, s1
+ N
);
40 std::make_heap(con
.begin(), con
.end());
41 std::sort_heap(con
.begin(), con
.end());
43 for(int i
= 1; i
< N
; ++i
)
44 VERIFY( s1
[i
].val
> s1
[i
- 1].val
&& s1
[i
].ok
);
50 V s1
[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7,
52 const int N
= sizeof(s1
) / sizeof(V
);
53 Container
con(s1
, s1
+ N
);
54 std::make_heap(con
.begin(), con
.end(), __gnu_test::order
);
55 std::sort_heap(con
.begin(), con
.end(), __gnu_test::order
);
57 for(int i
= 1; i
< N
; ++i
)
58 VERIFY( s1
[i
].val
> s1
[i
- 1].val
&& s1
[i
].ok
);
65 std::make_heap(vvs
, vvs
+ 2);
66 std::sort_heap(vvs
, vvs
+ 2);
67 VERIFY( vvs
[0].ok
&& vvs
[0].val
== 0 );
68 VERIFY( vvs
[1].ok
&& vvs
[1].val
== 2 );