OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc3/] [libstdc++-v3/] [testsuite/] [25_algorithms/] [stable_sort/] [moveable2.cc] - Blame information for rev 424

Go to most recent revision | 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 even 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.3.1.2 [lib.stable.sort]
21
 
22
#undef _GLIBCXX_CONCEPT_CHECKS
23
 
24
// XXX FIXME:  parallel-mode should deal correctly with moveable-only types
25
// per C++0x, at minimum smoothly fall back to serial.
26
#undef _GLIBCXX_PARALLEL
27
 
28
#include <algorithm>
29
#include <testsuite_hooks.h>
30
#include <testsuite_iterators.h>
31
#include <testsuite_rvalref.h>
32
 
33
using __gnu_test::test_container;
34
using __gnu_test::random_access_iterator_wrapper;
35
using __gnu_test::rvalstruct;
36
 
37
typedef test_container<rvalstruct, random_access_iterator_wrapper> Container;
38
 
39
const int A[] = { 10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7,
40
                  17, 8, 18, 9, 19 };
41
const int N = sizeof(A) / sizeof(int);
42
 
43
bool order(const rvalstruct& lhs, const rvalstruct& rhs)
44
{ return lhs < rhs; }
45
 
46
// 25.3.1.2 stable_sort()
47
void
48
test01()
49
{
50
  bool test __attribute__((unused)) = true;
51
 
52
  rvalstruct s1[N];
53
  std::copy(A, A + N, s1);
54
  Container con(s1, s1 + N);
55
  std::stable_sort(con.begin(), con.end(), order);
56
  VERIFY( s1[0].valid );
57
  for(int i = 1; i < N; ++i)
58
    VERIFY( s1[i].val>s1[i-1].val && s1[i].valid );
59
}
60
 
61
int
62
main()
63
{
64
  test01();
65
  return 0;
66
}

powered by: WebSVN 2.1.0

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