brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · a228976 Raw
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 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 >= 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.empty(), "");48  }49#endif50 51  return 0;52}53