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