]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/25_algorithms/sort/moveable.cc
re PR testsuite/39696 (gcc.dg/tree-ssa/ssa-ccp-25.c scan-tree-dump doesn't work on...
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 25_algorithms / sort / moveable.cc
CommitLineData
f5783e34
CJ
1// { dg-require-rvalref "" }
2// { dg-options "-std=gnu++0x" }
3
4// Copyright (C) 2005, 2007 Free Software Foundation, Inc.
5//
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 2, or (at your option)
10// any later version.
11
12// This library is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16
17// You should have received a copy of the GNU General Public License along
18// with this library; see the file COPYING. If not, write to the Free
19// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20// USA.
21
22// 25.3.1 algorithms, sort()
23
24#undef _GLIBCXX_CONCEPT_CHECKS
25#define _GLIBCXX_TESTSUITE_ALLOW_RVALREF_ALIASING
26
27#include <algorithm>
28#include <testsuite_hooks.h>
29#include <testsuite_iterators.h>
30#include <testsuite_rvalref.h>
31
32bool test __attribute__((unused)) = true;
33
34using __gnu_test::test_container;
35using __gnu_test::random_access_iterator_wrapper;
36using __gnu_test::rvalstruct;
37using std::partial_sort;
38
39typedef test_container<rvalstruct, random_access_iterator_wrapper> Container;
40
41
42const int A[] = {10, 20, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7,
43 17, 8, 18, 9, 19};
44const int N = sizeof(A) / sizeof(int);
45
46// 25.3.1.1 sort()
47void
48test01()
49{
50 rvalstruct s1[N];
51 std::copy(A, A + N, s1);
52 Container con(s1, s1 + N);
53 std::sort(con.begin(), con.end());
54 VERIFY(s1[0].valid);
55 for(int i = 1; i < N; ++i)
56 VERIFY(s1[i].val>s1[i-1].val && s1[i].valid);
57}
58
59int
60main()
61{
62 test01();
63 return 0;
64}