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
16using namespace std;
17
18class Class {};
19
20enum Enum1 {};
21#if __cplusplus >= 201103L
22enum class Enum2 : int {};
23#else
24enum Enum2 {};
25#endif
26
27template <class T>
28void test()
29{
30    static_assert(!std::is_void<T>::value, "");
31#if _LIBCPP_STD_VER > 11
32    static_assert(!std::is_null_pointer<T>::value, "");
33#endif
34    static_assert(!std::is_integral<T>::value, "");
35    static_assert(!std::is_floating_point<T>::value, "");
36    static_assert(!std::is_array<T>::value, "");
37    static_assert(!std::is_pointer<T>::value, "");
38    static_assert(!std::is_lvalue_reference<T>::value, "");
39    static_assert(!std::is_rvalue_reference<T>::value, "");
40    static_assert(!std::is_member_object_pointer<T>::value, "");
41    static_assert(!std::is_member_function_pointer<T>::value, "");
42    static_assert(!std::is_enum<T>::value, "");
43    static_assert(!std::is_union<T>::value, "");
44    static_assert(!std::is_class<T>::value, "");
45    static_assert( std::is_function<T>::value, "");
46}
47
48// Since we can't actually add the const volatile and ref qualifiers once
49// later let's use a macro to do it.
50#define TEST_REGULAR(...)                 \
51    test<__VA_ARGS__>();                  \
52    test<__VA_ARGS__ const>();            \
53    test<__VA_ARGS__ volatile>();         \
54    test<__VA_ARGS__ const volatile>()
55
56
57#define TEST_REF_QUALIFIED(...)           \
58    test<__VA_ARGS__ &>();                \
59    test<__VA_ARGS__ const &>();          \
60    test<__VA_ARGS__ volatile &>();       \
61    test<__VA_ARGS__ const volatile &>(); \
62    test<__VA_ARGS__ &&>();               \
63    test<__VA_ARGS__ const &&>();         \
64    test<__VA_ARGS__ volatile &&>();      \
65    test<__VA_ARGS__ const volatile &&>()
66
67
68int main()
69{
70    TEST_REGULAR( void () );
71    TEST_REGULAR( void (int) );
72    TEST_REGULAR( int (double) );
73    TEST_REGULAR( int (double, char) );
74    TEST_REGULAR( void (...) );
75    TEST_REGULAR( void (int, ...) );
76    TEST_REGULAR( int (double, ...) );
77    TEST_REGULAR( int (double, char, ...) );
78#if __cplusplus >= 201103L
79    TEST_REF_QUALIFIED( void () );
80    TEST_REF_QUALIFIED( void (int) );
81    TEST_REF_QUALIFIED( int (double) );
82    TEST_REF_QUALIFIED( int (double, char) );
83    TEST_REF_QUALIFIED( void (...) );
84    TEST_REF_QUALIFIED( void (int, ...) );
85    TEST_REF_QUALIFIED( int (double, ...) );
86    TEST_REF_QUALIFIED( int (double, char, ...) );
87#endif
88}
89