[flang][cuda] Do not apply implicit data attribute on dummy arg with VALUE (#119927)
[llvm-project.git] / libcxx / test / std / containers / sequences / array / array.cons / deduct.pass.cpp
blob30dd48e414b67be523e2dd52e37d58231e220828
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 //===----------------------------------------------------------------------===//
9 // <array>
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.
17 #include <array>
18 #include <cassert>
19 #include <cstddef>
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>>, "");
29 assert(arr[0] == 1);
30 assert(arr[1] == 2);
31 assert(arr[2] == 3);
35 const long l1 = 42;
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, "");
39 assert(arr[0] == 1);
40 assert(arr[1] == 4);
41 assert(arr[2] == 9);
42 assert(arr[3] == l1);
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);
55 return true;
58 int main(int, char**)
60 tests();
61 static_assert(tests(), "");
62 return 0;