1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <array> 10 11 // bool operator==(array<T, N> const&, array<T, N> const&); // constexpr in C++20 12 // bool operator!=(array<T, N> const&, array<T, N> const&); // constexpr in C++20 13 // bool operator<(array<T, N> const&, array<T, N> const&); // constexpr in C++20 14 // bool operator<=(array<T, N> const&, array<T, N> const&); // constexpr in C++20 15 // bool operator>(array<T, N> const&, array<T, N> const&); // constexpr in C++20 16 // bool operator>=(array<T, N> const&, array<T, N> const&); // constexpr in C++20 17 18 19 #include <array> 20 #include <cassert> 21 22 #include "test_macros.h" 23 #include "test_comparisons.h" 24 25 TEST_CONSTEXPR_CXX20 bool tests() 26 { 27 { 28 typedef std::array<int, 3> C; 29 const C c1 = {1, 2, 3}; 30 const C c2 = {1, 2, 3}; 31 const C c3 = {3, 2, 1}; 32 const C c4 = {1, 2, 1}; 33 assert(testComparisons(c1, c2, true, false)); 34 assert(testComparisons(c1, c3, false, true)); 35 assert(testComparisons(c1, c4, false, false)); 36 } 37 { 38 typedef std::array<int, 0> C; 39 const C c1 = {}; 40 const C c2 = {}; 41 assert(testComparisons(c1, c2, true, false)); 42 } 43 { 44 typedef std::array<LessAndEqComp, 3> C; 45 const C c1 = {LessAndEqComp(1), LessAndEqComp(2), LessAndEqComp(3)}; 46 const C c2 = {LessAndEqComp(1), LessAndEqComp(2), LessAndEqComp(3)}; 47 const C c3 = {LessAndEqComp(3), LessAndEqComp(2), LessAndEqComp(1)}; 48 const C c4 = {LessAndEqComp(1), LessAndEqComp(2), LessAndEqComp(1)}; 49 assert(testComparisons(c1, c2, true, false)); 50 assert(testComparisons(c1, c3, false, true)); 51 assert(testComparisons(c1, c4, false, false)); 52 } 53 { 54 typedef std::array<LessAndEqComp, 0> C; 55 const C c1 = {}; 56 const C c2 = {}; 57 assert(testComparisons(c1, c2, true, false)); 58 } 59 60 return true; 61 } 62 63 int main(int, char**) 64 { 65 tests(); 66 #if TEST_STD_VER >= 20 67 static_assert(tests(), ""); 68 #endif 69 return 0; 70 } 71