Eric Fiselier | 59cdf90 | 2018-02-07 21:06:13 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Chandler Carruth | 57b08b0 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 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 |
Eric Fiselier | 59cdf90 | 2018-02-07 21:06:13 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // <array> |
| 10 | |
Louis Dionne | 77b9abf | 2020-05-22 09:59:48 -0400 | [diff] [blame] | 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 |
Eric Fiselier | 59cdf90 | 2018-02-07 21:06:13 +0000 | [diff] [blame] | 17 | |
| 18 | |
| 19 | #include <array> |
Eric Fiselier | 59cdf90 | 2018-02-07 21:06:13 +0000 | [diff] [blame] | 20 | #include <cassert> |
| 21 | |
| 22 | #include "test_macros.h" |
Marshall Clow | 7c84e38 | 2018-08-03 00:47:12 +0000 | [diff] [blame] | 23 | #include "test_comparisons.h" |
Eric Fiselier | 59cdf90 | 2018-02-07 21:06:13 +0000 | [diff] [blame] | 24 | |
| 25 | // std::array is explicitly allowed to be initialized with A a = { init-list };. |
| 26 | // Disable the missing braces warning for this reason. |
| 27 | #include "disable_missing_braces_warning.h" |
| 28 | |
Louis Dionne | 77b9abf | 2020-05-22 09:59:48 -0400 | [diff] [blame] | 29 | TEST_CONSTEXPR_CXX20 bool tests() |
| 30 | { |
| 31 | { |
| 32 | typedef std::array<int, 3> C; |
| 33 | C c1 = {1, 2, 3}; |
| 34 | C c2 = {1, 2, 3}; |
| 35 | C c3 = {3, 2, 1}; |
| 36 | C c4 = {1, 2, 1}; |
| 37 | assert(testComparisons6(c1, c2, true, false)); |
| 38 | assert(testComparisons6(c1, c3, false, true)); |
| 39 | assert(testComparisons6(c1, c4, false, false)); |
| 40 | } |
| 41 | { |
| 42 | typedef std::array<int, 0> C; |
| 43 | C c1 = {}; |
| 44 | C c2 = {}; |
| 45 | assert(testComparisons6(c1, c2, true, false)); |
| 46 | } |
| 47 | |
| 48 | return true; |
| 49 | } |
| 50 | |
JF Bastien | 2df59c5 | 2019-02-04 20:31:13 +0000 | [diff] [blame] | 51 | int main(int, char**) |
Eric Fiselier | 59cdf90 | 2018-02-07 21:06:13 +0000 | [diff] [blame] | 52 | { |
Louis Dionne | 77b9abf | 2020-05-22 09:59:48 -0400 | [diff] [blame] | 53 | tests(); |
| 54 | #if TEST_STD_VER >= 20 |
| 55 | static_assert(tests(), ""); |
Marshall Clow | 07d8ac0 | 2018-08-02 02:11:06 +0000 | [diff] [blame] | 56 | #endif |
Louis Dionne | 77b9abf | 2020-05-22 09:59:48 -0400 | [diff] [blame] | 57 | return 0; |
Eric Fiselier | 59cdf90 | 2018-02-07 21:06:13 +0000 | [diff] [blame] | 58 | } |