]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/20_util/is_bounded_array/value.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 20_util / is_bounded_array / value.cc
CommitLineData
28d85efb
JW
1// { dg-options "-std=gnu++2a" }
2// { dg-do compile { target c++2a } }
3
83ffe9cd 4// Copyright (C) 2019-2023 Free Software Foundation, Inc.
28d85efb
JW
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#include <testsuite_tr1.h>
23
46610940
JW
24#ifndef __cpp_lib_bounded_array_traits
25# error "Feature test macro for is_bounded_array is missing"
26#elif __cpp_lib_bounded_array_traits < 201902L
27# error "Feature test macro for is_bounded_array has wrong value"
28#endif
29
28d85efb
JW
30void test01()
31{
32 using std::is_bounded_array;
33 using namespace __gnu_test;
34
35 static_assert(test_category<is_bounded_array, int[2]>(true), "");
36 static_assert(test_category<is_bounded_array, int[]>(false), "");
37 static_assert(test_category<is_bounded_array, int[2][3]>(true), "");
38 static_assert(test_category<is_bounded_array, int[][3]>(false), "");
39 static_assert(test_category<is_bounded_array, float*[2]>(true), "");
40 static_assert(test_category<is_bounded_array, float*[]>(false), "");
41 static_assert(test_category<is_bounded_array, float*[2][3]>(true), "");
42 static_assert(test_category<is_bounded_array, float*[][3]>(false), "");
43 static_assert(test_category<is_bounded_array, ClassType[2]>(true), "");
44 static_assert(test_category<is_bounded_array, ClassType[]>(false), "");
45 static_assert(test_category<is_bounded_array, ClassType[2][3]>(true), "");
46 static_assert(test_category<is_bounded_array, ClassType[][3]>(false), "");
47 static_assert(test_category<is_bounded_array, int(*)[2]>(false), "");
48 static_assert(test_category<is_bounded_array, int(*)[]>(false), "");
49 static_assert(test_category<is_bounded_array, int(&)[2]>(false), "");
50 static_assert(test_category<is_bounded_array, int(&)[]>(false), "");
51
52 // Sanity check.
53 static_assert(test_category<is_bounded_array, ClassType>(false), "");
54 static_assert(test_category<is_bounded_array, void()>(false), "");
55}
56
57template <class... T> void pos()
58{
59 static_assert((std::is_bounded_array_v<T> &&...));
60}
61
62template <class... T> void neg()
63{
64 static_assert((!std::is_bounded_array_v<T> &&...));
65}
66
67void test02()
68{
69 using namespace __gnu_test;
70 pos<int[2], int[2][3], float*[2], float*[2][3], ClassType[2],
71 ClassType[2][3]>();
72 neg<int[], int[][3], float*[], float*[][3], ClassType[],
73 ClassType[][3], int(*)[2], int(&)[], int(*)[2], int(&)[], ClassType>();
74}