]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/23_containers/array/comparison_operators/constexpr.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 23_containers / array / comparison_operators / constexpr.cc
CommitLineData
b9a2dce8 1// { dg-do compile { target c++20 } }
f4ab6846
JW
2// { dg-add-options no_pch }
3
a945c346 4// Copyright (C) 2019-2024 Free Software Foundation, Inc.
3a66e68a
ESR
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 3, 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 COPYING3. If not see
19// <http://www.gnu.org/licenses/>.
20
21#include <array>
22
e851aa17
JW
23#ifndef __cpp_lib_array_constexpr
24# error "Feature test macro for array constexpr is missing in <array>"
25#elif __cpp_lib_array_constexpr < 201806L
26# error "Feature test macro for array constexpr has wrong value in <array>"
27#endif
28
3a66e68a
ESR
29constexpr std::array<int, 3> a1{{1, 2, 3}};
30constexpr std::array<int, 3> a2{{4, 5, 6}};
31constexpr std::array<int, 3> a3{{1, 2, 4}};
32constexpr std::array<int, 3> a4{{1, 3, 3}};
33
34static_assert(a1 == a1);
35static_assert(a1 != a2);
36static_assert(a1 < a3);
37static_assert(a4 > a1);
38static_assert(a1 <= a3);
39static_assert(a4 >= a1);
3a4cc628
JW
40static_assert(std::is_eq(a1 <=> a1));
41static_assert(std::is_neq(a1 <=> a2));
42static_assert(std::is_lt(a1 <=> a3));
43static_assert(std::is_gt(a4 <=> a1));
44
45constexpr std::array<unsigned char, 3> a5{{1, 2, 3}};
46constexpr std::array<unsigned char, 3> a6{{4, 5, 6}};
47constexpr std::array<unsigned char, 3> a7{{1, 2, 4}};
48constexpr std::array<unsigned char, 3> a8{{1, 3, 3}};
49
50static_assert(a5 == a5);
51static_assert(a5 != a6);
52static_assert(a5 < a7);
53static_assert(a8 > a5);
54static_assert(a5 <= a7);
55static_assert(a8 >= a5);
56static_assert(std::is_eq(a5 <=> a5));
57static_assert(std::is_neq(a5 <=> a6));
58static_assert(std::is_lt(a5 <=> a7));
59static_assert(std::is_gt(a8 <=> a5));