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