OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc4/] [libstdc++-v3/] [testsuite/] [25_algorithms/] [stable_partition/] [moveable.cc] - Blame information for rev 519

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 424 jeremybenn
// { dg-options "-std=gnu++0x" }
2
 
3
// Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4
//
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)
9
// any later version.
10
 
11
// This library is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without Pred the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
 
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/>.
19
 
20
// 25.2.12 [lib.alg.partitions] Partitions.
21
 
22
// XXX FIXME:  parallel-mode should deal correctly with moveable-only types
23
// per C++0x, at minimum smoothly fall back to serial.
24
#undef _GLIBCXX_PARALLEL
25
 
26
#include <algorithm>
27
#include <functional>
28
#include <testsuite_hooks.h>
29
#include <testsuite_iterators.h>
30
#include <testsuite_rvalref.h>
31
 
32
using __gnu_test::test_container;
33
using __gnu_test::random_access_iterator_wrapper;
34
using __gnu_test::rvalstruct;
35
 
36
typedef test_container<rvalstruct, random_access_iterator_wrapper> Container;
37
 
38
const int A[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17};
39
const int B[] = {2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15, 17};
40
const int N = sizeof(A) / sizeof(int);
41
 
42
struct Pred
43
{
44
  bool
45
  operator()(const rvalstruct& x) const
46
  { return (x.val % 2) == 0; }
47
};
48
 
49
// 25.2.12 stable_partition()
50
void
51
test01()
52
{
53
  bool test __attribute__((unused)) = true;
54
 
55
  rvalstruct s1[N];
56
  std::copy(A, A + N, s1);
57
  Container con(s1, s1 + N);
58
 
59
  std::stable_partition(con.begin(), con.end(), Pred());
60
  VERIFY( std::equal(s1, s1 + N, B) );
61
}
62
 
63
int
64
main()
65
{
66
  test01();
67
  return 0;
68
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.