53 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <array>10 11// class array12 13// constexpr bool max_size() 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.max_size());25 assert(c.max_size() == 2);26 }27 {28 typedef std::array<int, 0> C;29 C c = {};30 ASSERT_NOEXCEPT(c.max_size());31 assert(c.max_size() == 0);32 }33 34 return true;35}36 37int main(int, char**) {38 tests();39#if TEST_STD_VER >= 1440 static_assert(tests(), "");41#endif42 43#if TEST_STD_VER >= 1144 // Sanity check for constexpr in C++1145 {46 constexpr std::array<int, 3> array = {};47 static_assert(array.max_size() == 3, "");48 }49#endif50 51 return 0;52}53