RISC-V: Make FRM as global register [PR118103]
[gcc.git] / libstdc++-v3 / testsuite / 25_algorithms / reverse / constrained.cc
blob492a8e8311b9fad6e8ccd38bd56bb0c950052091
1 // Copyright (C) 2020-2025 Free Software Foundation, Inc.
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.
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.
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/>.
18 // { dg-do run { target c++20 } }
20 #include <algorithm>
21 #include <testsuite_hooks.h>
22 #include <testsuite_iterators.h>
24 using __gnu_test::test_range;
25 using __gnu_test::test_container;
26 using __gnu_test::bidirectional_iterator_wrapper;
27 using __gnu_test::random_access_iterator_wrapper;
29 namespace ranges = std::ranges;
31 template<template<typename> typename wrapper>
32 void
33 test01()
35 int x[] = { 1, 2, 3, 4 };
36 test_container<int, wrapper> cx(x);
37 const int y[] = { 4, 3, 2, 1 };
39 auto res = ranges::reverse(cx);
40 VERIFY( res == ranges::end(cx) );
41 VERIFY( ranges::equal(cx, y) );
44 template<template<typename> typename wrapper>
45 void
46 test02()
48 int x[] = { 1, 2, 3, 4, 5 };
49 test_range<int, wrapper> rx(x);
50 const int y[] = { 5, 4, 3, 2, 1 };
52 auto res = ranges::reverse(rx);
53 VERIFY( res == ranges::end(rx) );
54 VERIFY( ranges::equal(rx, y) );
57 constexpr bool
58 test03()
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);
66 int
67 main()
69 test01<bidirectional_iterator_wrapper>();
70 test02<bidirectional_iterator_wrapper>();
72 test01<random_access_iterator_wrapper>();
73 test02<random_access_iterator_wrapper>();
75 static_assert(test03());