function.pass.cpp revision 7490f53118156f446b61583b7f0af0847b5942d7
1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// type_traits 11 12// function 13 14#include <type_traits> 15#include "test_macros.h" 16 17using namespace std; 18 19class Class {}; 20 21enum Enum1 {}; 22#if TEST_STD_VER >= 11 23enum class Enum2 : int {}; 24#else 25enum Enum2 {}; 26#endif 27 28template <class T> 29void test() 30{ 31 static_assert(!std::is_void<T>::value, ""); 32#if TEST_STD_VER > 11 33 static_assert(!std::is_null_pointer<T>::value, ""); 34#endif 35 static_assert(!std::is_integral<T>::value, ""); 36 static_assert(!std::is_floating_point<T>::value, ""); 37 static_assert(!std::is_array<T>::value, ""); 38 static_assert(!std::is_pointer<T>::value, ""); 39 static_assert(!std::is_lvalue_reference<T>::value, ""); 40 static_assert(!std::is_rvalue_reference<T>::value, ""); 41 static_assert(!std::is_member_object_pointer<T>::value, ""); 42 static_assert(!std::is_member_function_pointer<T>::value, ""); 43 static_assert(!std::is_enum<T>::value, ""); 44 static_assert(!std::is_union<T>::value, ""); 45 static_assert(!std::is_class<T>::value, ""); 46 static_assert( std::is_function<T>::value, ""); 47} 48 49// Since we can't actually add the const volatile and ref qualifiers once 50// later let's use a macro to do it. 51#define TEST_REGULAR(...) \ 52 test<__VA_ARGS__>(); \ 53 test<__VA_ARGS__ const>(); \ 54 test<__VA_ARGS__ volatile>(); \ 55 test<__VA_ARGS__ const volatile>() 56 57 58#define TEST_REF_QUALIFIED(...) \ 59 test<__VA_ARGS__ &>(); \ 60 test<__VA_ARGS__ const &>(); \ 61 test<__VA_ARGS__ volatile &>(); \ 62 test<__VA_ARGS__ const volatile &>(); \ 63 test<__VA_ARGS__ &&>(); \ 64 test<__VA_ARGS__ const &&>(); \ 65 test<__VA_ARGS__ volatile &&>(); \ 66 test<__VA_ARGS__ const volatile &&>() 67 68struct incomplete_type; 69 70int main() 71{ 72 TEST_REGULAR( void () ); 73 TEST_REGULAR( void (int) ); 74 TEST_REGULAR( int (double) ); 75 TEST_REGULAR( int (double, char) ); 76 TEST_REGULAR( void (...) ); 77 TEST_REGULAR( void (int, ...) ); 78 TEST_REGULAR( int (double, ...) ); 79 TEST_REGULAR( int (double, char, ...) ); 80#if TEST_STD_VER >= 11 81 TEST_REF_QUALIFIED( void () ); 82 TEST_REF_QUALIFIED( void (int) ); 83 TEST_REF_QUALIFIED( int (double) ); 84 TEST_REF_QUALIFIED( int (double, char) ); 85 TEST_REF_QUALIFIED( void (...) ); 86 TEST_REF_QUALIFIED( void (int, ...) ); 87 TEST_REF_QUALIFIED( int (double, ...) ); 88 TEST_REF_QUALIFIED( int (double, char, ...) ); 89#endif 90 91// LWG#2581 92 static_assert(!std::is_function<incomplete_type>::value, ""); 93} 94