Marshall Clow | fc6cc70 | 2017-11-15 02:31:14 +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 |
Marshall Clow | fc6cc70 | 2017-11-15 02:31:14 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // <array> |
| 10 | |
| 11 | // class array |
| 12 | |
Louis Dionne | 77b9abf | 2020-05-22 09:59:48 -0400 | [diff] [blame^] | 13 | // constexpr bool empty() const noexcept; |
Marshall Clow | fc6cc70 | 2017-11-15 02:31:14 +0000 | [diff] [blame] | 14 | |
| 15 | #include <array> |
| 16 | #include <cassert> |
| 17 | |
| 18 | #include "test_macros.h" |
Louis Dionne | 77b9abf | 2020-05-22 09:59:48 -0400 | [diff] [blame^] | 19 | |
| 20 | TEST_CONSTEXPR_CXX14 bool tests() |
| 21 | { |
| 22 | { |
| 23 | typedef std::array<int, 2> C; |
| 24 | C c = {}; |
| 25 | ASSERT_NOEXCEPT(c.empty()); |
| 26 | assert(!c.empty()); |
| 27 | } |
| 28 | { |
| 29 | typedef std::array<int, 0> C; |
| 30 | C c = {}; |
| 31 | ASSERT_NOEXCEPT(c.empty()); |
| 32 | assert(c.empty()); |
| 33 | } |
| 34 | |
| 35 | return true; |
| 36 | } |
Marshall Clow | fc6cc70 | 2017-11-15 02:31:14 +0000 | [diff] [blame] | 37 | |
JF Bastien | 2df59c5 | 2019-02-04 20:31:13 +0000 | [diff] [blame] | 38 | int main(int, char**) |
Marshall Clow | fc6cc70 | 2017-11-15 02:31:14 +0000 | [diff] [blame] | 39 | { |
Louis Dionne | 77b9abf | 2020-05-22 09:59:48 -0400 | [diff] [blame^] | 40 | tests(); |
| 41 | #if TEST_STD_VER >= 14 |
| 42 | static_assert(tests(), ""); |
| 43 | #endif |
JF Bastien | 2df59c5 | 2019-02-04 20:31:13 +0000 | [diff] [blame] | 44 | |
Louis Dionne | 77b9abf | 2020-05-22 09:59:48 -0400 | [diff] [blame^] | 45 | #if TEST_STD_VER >= 11 |
| 46 | // Sanity check for constexpr in C++11 |
| 47 | { |
| 48 | constexpr std::array<int, 3> array = {}; |
| 49 | static_assert(!array.empty(), ""); |
| 50 | } |
| 51 | #endif |
| 52 | |
| 53 | return 0; |
Marshall Clow | fc6cc70 | 2017-11-15 02:31:14 +0000 | [diff] [blame] | 54 | } |