brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · ba01200 Raw
56 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// template <class T, size_t N> constexpr size_type array<T,N>::size();12 13#include <array>14#include <cassert>15 16#include "test_macros.h"17 18int main(int, char**) {19  {20    typedef double T;21    typedef std::array<T, 3> C;22    C c = {1, 2, 3.5};23    assert(c.size() == 3);24    assert(c.max_size() == 3);25    assert(!c.empty());26  }27  {28    typedef double T;29    typedef std::array<T, 0> C;30    C c = {};31    assert(c.size() == 0);32    assert(c.max_size() == 0);33    assert(c.empty());34  }35#if TEST_STD_VER >= 1136  {37    typedef double T;38    typedef std::array<T, 3> C;39    constexpr C c = {1, 2, 3.5};40    static_assert(c.size() == 3, "");41    static_assert(c.max_size() == 3, "");42    static_assert(!c.empty(), "");43  }44  {45    typedef double T;46    typedef std::array<T, 0> C;47    constexpr C c = {};48    static_assert(c.size() == 0, "");49    static_assert(c.max_size() == 0, "");50    static_assert(c.empty(), "");51  }52#endif53 54  return 0;55}56