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 
18 // std::array is explicitly allowed to be initialized with A a = { init-list };.
19 // Disable the missing braces warning for this reason.
20 #include "disable_missing_braces_warning.h"
21 
main(int,char **)22 int main(int, char**)
23 {
24     {
25         typedef double T;
26         typedef std::array<T, 3> C;
27         C c = {1, 2, 3.5};
28         assert(c.size() == 3);
29         assert(c.max_size() == 3);
30         assert(!c.empty());
31     }
32     {
33         typedef double T;
34         typedef std::array<T, 0> C;
35         C c = {};
36         assert(c.size() == 0);
37         assert(c.max_size() == 0);
38         assert(c.empty());
39     }
40 #if TEST_STD_VER >= 11
41     {
42         typedef double T;
43         typedef std::array<T, 3> C;
44         constexpr C c = {1, 2, 3.5};
45         static_assert(c.size() == 3, "");
46         static_assert(c.max_size() == 3, "");
47         static_assert(!c.empty(), "");
48     }
49     {
50         typedef double T;
51         typedef std::array<T, 0> C;
52         constexpr C c = {};
53         static_assert(c.size() == 0, "");
54         static_assert(c.max_size() == 0, "");
55         static_assert(c.empty(), "");
56     }
57 #endif
58 
59   return 0;
60 }
61