| 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 | |
| 21 | namespace test_full_type { |
| 22 | template <class T, std::size_t S, std::array<T, S> A> |
| 23 | struct test : std::false_type {}; |
| 24 | |
| 25 | template <> |
| 26 | struct test<int, 3, std::array<int, 3>{1, 2, 3}> : std::true_type {}; |
| 27 | |
| 28 | static_assert(!test<int*, 4, std::array<int*, 4>{}>::value); |
| 29 | static_assert(!test<int*, 3, std::array<int*, 3>{}>::value); |
| 30 | static_assert(!test<int, 3, std::array<int, 3>{}>::value); |
| 31 | static_assert(!test<int, 3, std::array<int, 3>{1}>::value); |
| 32 | static_assert(!test<int, 3, std::array<int, 3>{1, 2}>::value); |
| 33 | static_assert(!test<long, 3, std::array<long, 3>{1, 2, 3}>::value); |
| 34 | static_assert(!test<unsigned int, 3, std::array<unsigned int, 3>{1, 2, 3}>::value); |
| 35 | static_assert(test<int, 3, std::array<int, 3>{1, 2, 3}>::value); |
| 36 | } // namespace test_full_type |
| 37 | |
| 38 | namespace test_ctad { |
| 39 | template <std::array A> |
| 40 | struct test : std::false_type {}; |
| 41 | |
| 42 | template <> |
| 43 | struct test<std::array<int, 3>{4, 5, 6}> : std::true_type {}; |
| 44 | |
| 45 | static_assert(!test<std::array<int*, 4>{}>::value); |
| 46 | static_assert(!test<std::array<int*, 3>{}>::value); |
| 47 | static_assert(!test<std::array<int, 3>{}>::value); |
| 48 | static_assert(!test<std::array<int, 3>{4}>::value); |
| 49 | static_assert(!test<std::array<int, 3>{4, 5}>::value); |
| 50 | static_assert(!test<std::array<long, 3>{4, 5, 6}>::value); |
| 51 | static_assert(!test<std::array<unsigned int, 3>{4, 5, 6}>::value); |
| 52 | static_assert(test<std::array<int, 3>{4, 5, 6}>::value); |
| 53 | } // namespace test_ctad |
| 54 | |
| 55 | namespace test_auto { |
| 56 | template <auto A> |
| 57 | struct test : std::false_type {}; |
| 58 | |
| 59 | template <> |
| 60 | struct test<std::array<int, 3>{7, 8, 9}> : std::true_type {}; |
| 61 | |
| 62 | static_assert(!test<std::array<int*, 4>{}>::value); |
| 63 | static_assert(!test<std::array<int*, 3>{}>::value); |
| 64 | static_assert(!test<std::array<int, 3>{}>::value); |
| 65 | static_assert(!test<std::array<int, 3>{7}>::value); |
| 66 | static_assert(!test<std::array<int, 3>{7, 8}>::value); |
| 67 | static_assert(!test<std::array<long, 3>{7, 8, 9}>::value); |
| 68 | static_assert(!test<std::array<unsigned int, 3>{7, 8, 9}>::value); |
| 69 | static_assert(test<std::array<int, 3>{7, 8, 9}>::value); |
| 70 | } // namespace test_auto |
| 71 | |