brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 1fc79cf Raw
93 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 9// type_traits10 11// function12 13#include <type_traits>14#include "test_macros.h"15 16class Class {};17 18enum Enum1 {};19#if TEST_STD_VER >= 1120enum class Enum2 : int {};21#else22enum Enum2 {};23#endif24 25template <class T>26void test()27{28    static_assert(!std::is_void<T>::value, "");29#if TEST_STD_VER > 1130    static_assert(!std::is_null_pointer<T>::value, "");31#endif32    static_assert(!std::is_integral<T>::value, "");33    static_assert(!std::is_floating_point<T>::value, "");34    static_assert(!std::is_array<T>::value, "");35    static_assert(!std::is_pointer<T>::value, "");36    static_assert(!std::is_lvalue_reference<T>::value, "");37    static_assert(!std::is_rvalue_reference<T>::value, "");38    static_assert(!std::is_member_object_pointer<T>::value, "");39    static_assert(!std::is_member_function_pointer<T>::value, "");40    static_assert(!std::is_enum<T>::value, "");41    static_assert(!std::is_union<T>::value, "");42    static_assert(!std::is_class<T>::value, "");43    static_assert( std::is_function<T>::value, "");44}45 46// Since we can't actually add the const volatile and ref qualifiers once47// later let's use a macro to do it.48#define TEST_REGULAR(...)                 \49    test<__VA_ARGS__>();                  \50    test<__VA_ARGS__ const>();            \51    test<__VA_ARGS__ volatile>();         \52    test<__VA_ARGS__ const volatile>()53 54 55#define TEST_REF_QUALIFIED(...)           \56    test<__VA_ARGS__ &>();                \57    test<__VA_ARGS__ const &>();          \58    test<__VA_ARGS__ volatile &>();       \59    test<__VA_ARGS__ const volatile &>(); \60    test<__VA_ARGS__ &&>();               \61    test<__VA_ARGS__ const &&>();         \62    test<__VA_ARGS__ volatile &&>();      \63    test<__VA_ARGS__ const volatile &&>()64 65struct incomplete_type;66 67int main(int, char**)68{69    TEST_REGULAR( void () );70    TEST_REGULAR( void (int) );71    TEST_REGULAR( int (double) );72    TEST_REGULAR( int (double, char) );73    TEST_REGULAR( void (...) );74    TEST_REGULAR( void (int, ...) );75    TEST_REGULAR( int (double, ...) );76    TEST_REGULAR( int (double, char, ...) );77#if TEST_STD_VER >= 1178    TEST_REF_QUALIFIED( void () );79    TEST_REF_QUALIFIED( void (int) );80    TEST_REF_QUALIFIED( int (double) );81    TEST_REF_QUALIFIED( int (double, char) );82    TEST_REF_QUALIFIED( void (...) );83    TEST_REF_QUALIFIED( void (int, ...) );84    TEST_REF_QUALIFIED( int (double, ...) );85    TEST_REF_QUALIFIED( int (double, char, ...) );86#endif87 88//  LWG#258289    static_assert(!std::is_function<incomplete_type>::value, "");90 91  return 0;92}93