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// class array
12
13// constexpr bool empty() const noexcept;
14
15#include <array>
16#include <cassert>
17
18#include "test_macros.h"
19
20TEST_CONSTEXPR_CXX14 bool tests() {
21 {
22 typedef std::array<int, 2> C;
23 C c = {};
24 ASSERT_NOEXCEPT(c.empty());
25 assert(!c.empty());
26 }
27 {
28 typedef std::array<int, 0> C;
29 C c = {};
30 ASSERT_NOEXCEPT(c.empty());
31 assert(c.empty());
32 }
33
34 return true;
35}
36
37int main(int, char**) {
38 tests();
39#if TEST_STD_VER >= 14
40 static_assert(tests(), "");
41#endif
42
43#if TEST_STD_VER >= 11
44 // Sanity check for constexpr in C++11
45 {
46 constexpr std::array<int, 3> array = {};
47 static_assert(!array.empty(), "");
48 }
49#endif
50
51 return 0;
52}
53

source code of libcxx/test/std/containers/sequences/array/empty.pass.cpp