1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
10 // UNSUPPORTED: c++03, c++11, c++14
12 // template <class T, class... U>
13 // array(T, U...) -> array<T, 1 + sizeof...(U)>;
15 // Requires: (is_same_v<T, U> && ...) is true. Otherwise the program is ill-formed.
21 #include "test_macros.h"
23 constexpr bool tests()
25 // Test the explicit deduction guides
27 std::array arr
{1,2,3}; // array(T, U...)
28 static_assert(std::is_same_v
<decltype(arr
), std::array
<int, 3>>, "");
36 std::array arr
{1L, 4L, 9L, l1
}; // array(T, U...)
37 static_assert(std::is_same_v
<decltype(arr
)::value_type
, long>, "");
38 static_assert(arr
.size() == 4, "");
45 // Test the implicit deduction guides
47 std::array
<double, 2> source
= {4.0, 5.0};
48 std::array
arr(source
); // array(array)
49 static_assert(std::is_same_v
<decltype(arr
), decltype(source
)>, "");
50 static_assert(std::is_same_v
<decltype(arr
), std::array
<double, 2>>, "");
51 assert(arr
[0] == 4.0);
52 assert(arr
[1] == 5.0);
61 static_assert(tests(), "");