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// 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 {
21 typedef double T;
22 typedef std::array<T, 3> C;
23 C c = {1, 2, 3.5};
24 assert(c.size() == 3);
25 assert(c.max_size() == 3);
26 assert(!c.empty());
27 }
28 {
29 typedef double T;
30 typedef std::array<T, 0> C;
31 C c = {};
32 assert(c.size() == 0);
33 assert(c.max_size() == 0);
34 assert(c.empty());
35 }
36#if TEST_STD_VER >= 11
37 {
38 typedef double T;
39 typedef std::array<T, 3> C;
40 constexpr C c = {1, 2, 3.5};
41 static_assert(c.size() == 3, "");
42 static_assert(c.max_size() == 3, "");
43 static_assert(!c.empty(), "");
44 }
45 {
46 typedef double T;
47 typedef std::array<T, 0> C;
48 constexpr C c = {};
49 static_assert(c.size() == 0, "");
50 static_assert(c.max_size() == 0, "");
51 static_assert(c.empty(), "");
52 }
53#endif
54
55 return 0;
56}
57

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