]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/25_algorithms/reverse/constrained.cc
libstdc++: Remove dg-options "-std=gnu++2a" from constrained algo tests
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 25_algorithms / reverse / constrained.cc
CommitLineData
83ffe9cd 1// Copyright (C) 2020-2023 Free Software Foundation, Inc.
bc464641
PP
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
6// Free Software Foundation; either version 3, or (at your option)
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
17
7dbb6913 18// { dg-do run { target c++20 } }
bc464641
PP
19
20#include <algorithm>
21#include <testsuite_hooks.h>
22#include <testsuite_iterators.h>
23
24using __gnu_test::test_range;
25using __gnu_test::test_container;
26using __gnu_test::bidirectional_iterator_wrapper;
27using __gnu_test::random_access_iterator_wrapper;
28
29namespace ranges = std::ranges;
30
31template<template<typename> typename wrapper>
32void
33test01()
34{
35 int x[] = { 1, 2, 3, 4 };
36 test_container<int, wrapper> cx(x);
37 const int y[] = { 4, 3, 2, 1 };
38
39 auto res = ranges::reverse(cx);
40 VERIFY( res == ranges::end(cx) );
41 VERIFY( ranges::equal(cx, y) );
42}
43
44template<template<typename> typename wrapper>
45void
46test02()
47{
48 int x[] = { 1, 2, 3, 4, 5 };
49 test_range<int, wrapper> rx(x);
50 const int y[] = { 5, 4, 3, 2, 1 };
51
52 auto res = ranges::reverse(rx);
53 VERIFY( res == ranges::end(rx) );
54 VERIFY( ranges::equal(rx, y) );
55}
56
57constexpr bool
58test03()
59{
60 int x[] = { 1, 2, 3 };
61 const int y[] = { 2, 1, 3 };
62 ranges::reverse(x, x+2);
63 return ranges::equal(x, y);
64}
65
66int
67main()
68{
69 test01<bidirectional_iterator_wrapper>();
70 test02<bidirectional_iterator_wrapper>();
71
72 test01<random_access_iterator_wrapper>();
73 test02<random_access_iterator_wrapper>();
74
75 static_assert(test03());
76}