Debian Codegraph @

libcxx/test/std/utilities/meta/meta.unary/meta.unary.comp/is_bounded_array.pass.cpp

raw
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 // UNSUPPORTED: c++03, c++11, c++14, c++17
9
10 // type_traits
11
12 // is_bounded_array<T>
13 // T is an array type of known bound ([dcl.array])
14
15 #include <type_traits>
16 #include <cstddef>
17
18 #include "test_macros.h"
19
20 template <class T, bool B>
21 void test_array_imp()
22 {
23 static_assert( B == std::is_bounded_array<T>::value, "" );
24 static_assert( B == std::is_bounded_array_v<T>, "" );
25 }
26
27 template <class T, bool B>
28 void test_array()
29 {
30 test_array_imp<T, B>();
31 test_array_imp<const T, B>();
32 test_array_imp<volatile T, B>();
33 test_array_imp<const volatile T, B>();
34 }
35
36 class incomplete_type;
37
38 class Empty {};
39 union Union {};
40
41 class Abstract
42 {
43 virtual ~Abstract() = 0;
44 };
45
46 enum Enum {zero, one};
47 typedef void (*FunctionPtr)();
48
49 int main(int, char**)
50 {
51 // Non-array types
52 test_array<void, false>();
53 test_array<std::nullptr_t, false>();
54 test_array<int, false>();
55 test_array<double, false>();
56 test_array<void *, false>();
57 test_array<int &, false>();
58 test_array<int &&, false>();
59 test_array<Empty, false>();
60 test_array<Union, false>();
61 test_array<Abstract, false>();
62 test_array<Enum, false>();
63 test_array<FunctionPtr, false>();
64
65 // Array types
66 test_array<char[3], true>();
67 test_array<int[0], false>();
68 test_array<char[], false>();
69 test_array<incomplete_type[], false>();
70
71 return 0;
72 }