]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/25_algorithms/equal/94013.cc
1 // Copyright (C) 2020-2021 Free Software Foundation, Inc.
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)
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/>.
21 #include <testsuite_hooks.h>
26 volatile int i
[] = { 0, 1, 2, 3 };
27 volatile int j
[] = { 1, 2, 3 };
28 int k
[] = { 2, 3, 4 };
30 VERIFY( std::equal(i
+1, i
+4, j
) ); // volatile, volatile
31 VERIFY( std::equal(i
+2, i
+4, k
) ); // volatile, unqual
32 VERIFY( ! std::equal(k
, k
+3, i
+1) ); // unqual, volatile
34 const volatile int* cj
= j
;
35 VERIFY( ! std::equal(cj
, cj
+2, cj
+1) ); // const volatile, const volatile
36 VERIFY( std::equal(cj
, cj
+3, i
+1) ); // const volatile, volatile
37 VERIFY( ! std::equal(i
, i
+2, cj
) ); // volatile, const volatile
38 VERIFY( std::equal(cj
+1, cj
+3, k
) ); // const volatile, unqual
39 VERIFY( ! std::equal(k
, k
+2, cj
) ); // unqual, const volatile
41 VERIFY( std::equal(ck
, ck
+2, i
+2) ); // const, volatile
42 VERIFY( ! std::equal(i
, i
+3, ck
) ); // volatile, const
43 VERIFY( std::equal(cj
+1, cj
+3, ck
) ); // const volatile, const
44 VERIFY( ! std::equal(ck
, ck
+1, cj
) ); // const, const volatile
46 #if __cplusplus > 201703L
47 using std::ranges::equal
;
48 VERIFY( equal(i
+1, i
+4, j
, j
+3) ); // volatile, volatile
49 VERIFY( equal(i
+2, i
+4, k
, k
+2) ); // volatile, unqual
50 VERIFY( ! equal(k
, k
+3, i
+1, i
+4) ); // unqual, volatile
52 VERIFY( ! equal(cj
, cj
+2, cj
+1, cj
+3) );// const volatile, const volatile
53 VERIFY( equal(cj
, cj
+3, i
+1, i
+4) ); // const volatile, volatile
54 VERIFY( ! equal(i
, i
+2, cj
, cj
+2) ); // volatile, const volatile
55 VERIFY( equal(cj
+1, cj
+3, k
, k
+2) ); // const volatile, unqual
56 VERIFY( ! equal(k
, k
+2, cj
, cj
+2) ); // unqual, const volatile
58 VERIFY( equal(ck
, ck
+2, i
+2, i
+4) ); // const, volatile
59 VERIFY( ! equal(i
, i
+3, ck
, ck
+3) ); // volatile, const
60 VERIFY( equal(cj
+1, cj
+3, ck
, ck
+2) ); // const volatile, const
61 VERIFY( ! equal(ck
, ck
+1, cj
, cj
+1) ); // const, const volatile