1 // { dg-options "-std=gnu++0x" }
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
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 Pred 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.2.12 [lib.alg.partitions] Partitions.
23 #undef _GLIBCXX_CONCEPT_CHECKS
27 #include <testsuite_hooks.h>
28 #include <testsuite_rvalref.h>
29 #include <testsuite_iterators.h>
31 using __gnu_test::test_container;
32 using __gnu_test::forward_iterator_wrapper;
33 using __gnu_test::bidirectional_iterator_wrapper;
34 using __gnu_test::rvalstruct;
36 typedef test_container<rvalstruct, forward_iterator_wrapper> Fcontainer;
37 typedef test_container<rvalstruct, bidirectional_iterator_wrapper> Bcontainer;
39 bool test __attribute__((unused)) = true;
41 const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
42 const int B[] = {2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15, 17};
43 const int N = sizeof(A) / sizeof(int);
48 operator()(const rvalstruct& x) const
49 { return (x.val % 2) == 0; }
52 // 25.2.12 partition()
61 std::copy(A, A + N, farray);
62 std::copy(A, A + N, barray);
64 Fcontainer fcon(farray, farray + N);
65 Bcontainer bcon(barray, barray + N);
69 VERIFY(partition(fcon.begin(), fcon.end(), pred).ptr - farray == N/2);
70 for (const rvalstruct* i = farray; i < farray+N/2; ++i)
73 for (const rvalstruct* i = farray+N/2; i < farray + N; ++i)
76 VERIFY(partition(bcon.begin(), bcon.end(), pred).ptr - barray == N/2);
78 for (const rvalstruct* i = barray; i < barray+N/2; ++i)
80 for (const rvalstruct* i = barray+N/2; i < barray + N; ++i)