| 1 | // { dg-do compile { target c++20 } } |
| 2 | // { dg-add-options no_pch } |
| 3 | |
| 4 | // Copyright (C) 2019-2025 Free Software Foundation, Inc. |
| 5 | // |
| 6 | // This file is part of the GNU ISO C++ Library. This library is free |
| 7 | // software; you can redistribute it and/or modify it under the |
| 8 | // terms of the GNU General Public License as published by the |
| 9 | // Free Software Foundation; either version 3, or (at your option) |
| 10 | // any later version. |
| 11 | // |
| 12 | // This library is distributed in the hope that it will be useful, |
| 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | // GNU General Public License for more details. |
| 16 | // |
| 17 | // You should have received a copy of the GNU General Public License along |
| 18 | // with this library; see the file COPYING3. If not see |
| 19 | // <http://www.gnu.org/licenses/>. |
| 20 | |
| 21 | #include <type_traits> |
| 22 | |
| 23 | #ifndef __cpp_lib_bounded_array_traits |
| 24 | # error "Feature test macro for is_unbounded_array is missing" |
| 25 | #elif __cpp_lib_bounded_array_traits < 201902L |
| 26 | # error "Feature test macro for is_unbounded_array has wrong value" |
| 27 | #endif |
| 28 | |
| 29 | #include <testsuite_tr1.h> |
| 30 | |
| 31 | void test01() |
| 32 | { |
| 33 | using std::is_unbounded_array; |
| 34 | using namespace __gnu_test; |
| 35 | |
| 36 | static_assert(test_category<is_unbounded_array, int[2]>(false), ""); |
| 37 | static_assert(test_category<is_unbounded_array, int[]>(true), ""); |
| 38 | static_assert(test_category<is_unbounded_array, int[2][3]>(false), ""); |
| 39 | static_assert(test_category<is_unbounded_array, int[][3]>(true), ""); |
| 40 | static_assert(test_category<is_unbounded_array, float*[2]>(false), ""); |
| 41 | static_assert(test_category<is_unbounded_array, float*[]>(true), ""); |
| 42 | static_assert(test_category<is_unbounded_array, float*[2][3]>(false), ""); |
| 43 | static_assert(test_category<is_unbounded_array, float*[][3]>(true), ""); |
| 44 | static_assert(test_category<is_unbounded_array, ClassType[2]>(false), ""); |
| 45 | static_assert(test_category<is_unbounded_array, ClassType[]>(true), ""); |
| 46 | static_assert(test_category<is_unbounded_array, ClassType[2][3]>(false), ""); |
| 47 | static_assert(test_category<is_unbounded_array, ClassType[][3]>(true), ""); |
| 48 | static_assert(test_category<is_unbounded_array, IncompleteClass[2][3]>(false), ""); |
| 49 | static_assert(test_category<is_unbounded_array, IncompleteClass[][3]>(true), ""); |
| 50 | static_assert(test_category<is_unbounded_array, int(*)[2]>(false), ""); |
| 51 | static_assert(test_category<is_unbounded_array, int(*)[]>(false), ""); |
| 52 | static_assert(test_category<is_unbounded_array, int(&)[2]>(false), ""); |
| 53 | static_assert(test_category<is_unbounded_array, int(&)[]>(false), ""); |
| 54 | |
| 55 | // Sanity check. |
| 56 | static_assert(test_category<is_unbounded_array, ClassType>(false), ""); |
| 57 | static_assert(test_category<is_unbounded_array, IncompleteClass>(false), ""); |
| 58 | static_assert(test_category<is_unbounded_array, IncompleteUnion>(false), ""); |
| 59 | } |
| 60 | |
| 61 | template <class... T> void pos() |
| 62 | { |
| 63 | static_assert((std::is_unbounded_array_v<T> &&...)); |
| 64 | } |
| 65 | |
| 66 | template <class... T> void neg() |
| 67 | { |
| 68 | static_assert((!std::is_unbounded_array_v<T> &&...)); |
| 69 | } |
| 70 | |
| 71 | void test02() |
| 72 | { |
| 73 | using namespace __gnu_test; |
| 74 | pos<int[], int[][3], float*[], float*[][3], ClassType[], |
| 75 | ClassType[][3]>(); |
| 76 | neg<int[2], int[2][3], float*[2], float*[2][3], ClassType[2], |
| 77 | ClassType[2][3], int(*)[2], int(&)[], int(*)[2], int(&)[], ClassType>(); |
| 78 | } |