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 // These are all constexpr in C++20 12 // bool operator==(array<T, N> const&, array<T, N> const&); 13 // bool operator!=(array<T, N> const&, array<T, N> const&); 14 // bool operator<(array<T, N> const&, array<T, N> const&); 15 // bool operator<=(array<T, N> const&, array<T, N> const&); 16 // bool operator>(array<T, N> const&, array<T, N> const&); 17 // bool operator>=(array<T, N> const&, array<T, N> const&); 18 19 20 #include <array> 21 #include <vector> 22 #include <cassert> 23 24 #include "test_macros.h" 25 #include "test_comparisons.h" 26 27 // std::array is explicitly allowed to be initialized with A a = { init-list };. 28 // Disable the missing braces warning for this reason. 29 #include "disable_missing_braces_warning.h" 30 31 int main(int, char**) 32 { 33 { 34 typedef int T; 35 typedef std::array<T, 3> C; 36 C c1 = {1, 2, 3}; 37 C c2 = {1, 2, 3}; 38 C c3 = {3, 2, 1}; 39 C c4 = {1, 2, 1}; 40 assert(testComparisons6(c1, c2, true, false)); 41 assert(testComparisons6(c1, c3, false, true)); 42 assert(testComparisons6(c1, c4, false, false)); 43 } 44 { 45 typedef int T; 46 typedef std::array<T, 0> C; 47 C c1 = {}; 48 C c2 = {}; 49 assert(testComparisons6(c1, c2, true, false)); 50 } 51 52 #if TEST_STD_VER > 17 53 { 54 constexpr std::array<int, 3> a1 = {1, 2, 3}; 55 constexpr std::array<int, 3> a2 = {2, 3, 4}; 56 static_assert(testComparisons6(a1, a1, true, false), ""); 57 static_assert(testComparisons6(a1, a2, false, true), ""); 58 static_assert(testComparisons6(a2, a1, false, false), ""); 59 } 60 #endif 61 62 return 0; 63 } 64