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// UNSUPPORTED: c++03, c++11, c++14, c++17
10
11// <array>
12
13// LWG-3382 NTTP for pair and array:
14// Two values a1 and a2 of type array<T, N> are template-argument-equivalent if and only if each pair of corresponding
15// elements in a1 and a2 are template-argument-equivalent.
16
17#include <array>
18
19#include <type_traits>
20
21namespace test_full_type {
22template <class T, std::size_t S, std::array<T, S> A>
23struct test : std::false_type {};
24
25template <>
26struct test<int, 3, std::array<int, 3>{1, 2, 3}> : std::true_type {};
27
28static_assert(!test<int*, 4, std::array<int*, 4>{}>::value);
29static_assert(!test<int*, 3, std::array<int*, 3>{}>::value);
30static_assert(!test<int, 3, std::array<int, 3>{}>::value);
31static_assert(!test<int, 3, std::array<int, 3>{1}>::value);
32static_assert(!test<int, 3, std::array<int, 3>{1, 2}>::value);
33static_assert(!test<long, 3, std::array<long, 3>{1, 2, 3}>::value);
34static_assert(!test<unsigned int, 3, std::array<unsigned int, 3>{1, 2, 3}>::value);
35static_assert(test<int, 3, std::array<int, 3>{1, 2, 3}>::value);
36} // namespace test_full_type
37
38namespace test_ctad {
39template <std::array A>
40struct test : std::false_type {};
41
42template <>
43struct test<std::array<int, 3>{4, 5, 6}> : std::true_type {};
44
45static_assert(!test<std::array<int*, 4>{}>::value);
46static_assert(!test<std::array<int*, 3>{}>::value);
47static_assert(!test<std::array<int, 3>{}>::value);
48static_assert(!test<std::array<int, 3>{4}>::value);
49static_assert(!test<std::array<int, 3>{4, 5}>::value);
50static_assert(!test<std::array<long, 3>{4, 5, 6}>::value);
51static_assert(!test<std::array<unsigned int, 3>{4, 5, 6}>::value);
52static_assert(test<std::array<int, 3>{4, 5, 6}>::value);
53} // namespace test_ctad
54
55namespace test_auto {
56template <auto A>
57struct test : std::false_type {};
58
59template <>
60struct test<std::array<int, 3>{7, 8, 9}> : std::true_type {};
61
62static_assert(!test<std::array<int*, 4>{}>::value);
63static_assert(!test<std::array<int*, 3>{}>::value);
64static_assert(!test<std::array<int, 3>{}>::value);
65static_assert(!test<std::array<int, 3>{7}>::value);
66static_assert(!test<std::array<int, 3>{7, 8}>::value);
67static_assert(!test<std::array<long, 3>{7, 8, 9}>::value);
68static_assert(!test<std::array<unsigned int, 3>{7, 8, 9}>::value);
69static_assert(test<std::array<int, 3>{7, 8, 9}>::value);
70} // namespace test_auto
71

source code of libcxx/test/std/containers/sequences/array/array.overview/nttp.equivalence.compile.pass.cpp