1 // { dg-options "-std=gnu++11" }
3 // Copyright (C) 2005-2015 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 // 25.2.12 [lib.alg.partitions] Partitions.
22 #undef _GLIBCXX_CONCEPT_CHECKS
26 #include <testsuite_hooks.h>
27 #include <testsuite_rvalref.h>
28 #include <testsuite_iterators.h>
30 using __gnu_test::test_container
;
31 using __gnu_test::forward_iterator_wrapper
;
32 using __gnu_test::bidirectional_iterator_wrapper
;
33 using __gnu_test::rvalstruct
;
35 typedef test_container
<rvalstruct
, forward_iterator_wrapper
> Fcontainer
;
36 typedef test_container
<rvalstruct
, bidirectional_iterator_wrapper
> Bcontainer
;
38 bool test
__attribute__((unused
)) = true;
40 const int A
[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
41 const int B
[] = {2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15, 17};
42 const int N
= sizeof(A
) / sizeof(int);
47 operator()(const rvalstruct
& x
) const
48 { return (x
.val
% 2) == 0; }
51 // 25.2.12 partition()
60 std::copy(A
, A
+ N
, farray
);
61 std::copy(A
, A
+ N
, barray
);
63 Fcontainer
fcon(farray
, farray
+ N
);
64 Bcontainer
bcon(barray
, barray
+ N
);
68 VERIFY(partition(fcon
.begin(), fcon
.end(), pred
).ptr
- farray
== N
/2);
69 for (const rvalstruct
* i
= farray
; i
< farray
+N
/2; ++i
)
72 for (const rvalstruct
* i
= farray
+N
/2; i
< farray
+ N
; ++i
)
75 VERIFY(partition(bcon
.begin(), bcon
.end(), pred
).ptr
- barray
== N
/2);
77 for (const rvalstruct
* i
= barray
; i
< barray
+N
/2; ++i
)
79 for (const rvalstruct
* i
= barray
+N
/2; i
< barray
+ N
; ++i
)