1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <array>
11
12 // template <class T, size_t N> constexpr size_type array<T,N>::size();
13
14 #include <array>
15 #include <cassert>
16
17 #include "test_macros.h"
18
19 // std::array is explicitly allowed to be initialized with A a = { init-list };.
20 // Disable the missing braces warning for this reason.
21 #include "disable_missing_braces_warning.h"
22
main()23 int main()
24 {
25 {
26 typedef double T;
27 typedef std::array<T, 3> C;
28 C c = {1, 2, 3.5};
29 assert(c.size() == 3);
30 assert(c.max_size() == 3);
31 assert(!c.empty());
32 }
33 {
34 typedef double T;
35 typedef std::array<T, 0> C;
36 C c = {};
37 assert(c.size() == 0);
38 assert(c.max_size() == 0);
39 assert(c.empty());
40 }
41 #if TEST_STD_VER >= 11
42 {
43 typedef double T;
44 typedef std::array<T, 3> C;
45 constexpr C c = {1, 2, 3.5};
46 static_assert(c.size() == 3, "");
47 static_assert(c.max_size() == 3, "");
48 static_assert(!c.empty(), "");
49 }
50 {
51 typedef double T;
52 typedef std::array<T, 0> C;
53 constexpr C c = {};
54 static_assert(c.size() == 0, "");
55 static_assert(c.max_size() == 0, "");
56 static_assert(c.empty(), "");
57 }
58 #endif
59 }
60