brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 8e57e89 Raw
73 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8// UNSUPPORTED: c++03, c++11, c++14, c++179 10// type_traits11 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 20template <class T, bool B>21void 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 27template <class T, bool B>28void 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 36class incomplete_type;37 38class Empty {};39union Union {};40 41class Abstract42{43    virtual ~Abstract() = 0;44};45 46enum Enum {zero, one};47typedef void (*FunctionPtr)();48 49int main(int, char**)50{51    // Non-array types52    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 types66    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}73