1c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//===----------------------------------------------------------------------===//
2c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//
3c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//                     The LLVM Compiler Infrastructure
4c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//
5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// This file is dual licensed under the MIT and the University of Illinois Open
6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// Source Licenses. See LICENSE.TXT for details.
7c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//
8c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant//===----------------------------------------------------------------------===//
9c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
10c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// type_traits
11c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
12c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant// function
13c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
14c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant#include <type_traits>
157490f53118156f446b61583b7f0af0847b5942d7Marshall Clow#include "test_macros.h"
16c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
1789465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselierusing namespace std;
1889465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier
1989465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselierclass Class {};
2089465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier
2189465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselierenum Enum1 {};
227490f53118156f446b61583b7f0af0847b5942d7Marshall Clow#if TEST_STD_VER >= 11
2389465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselierenum class Enum2 : int {};
2489465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier#else
2589465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselierenum Enum2 {};
2689465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier#endif
2789465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier
28c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnanttemplate <class T>
2989465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiseliervoid test()
30c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant{
31c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    static_assert(!std::is_void<T>::value, "");
327490f53118156f446b61583b7f0af0847b5942d7Marshall Clow#if TEST_STD_VER > 11
3379d8c99a62b6a6fa0b3c0dc3f761659f62f3f587Marshall Clow    static_assert(!std::is_null_pointer<T>::value, "");
3479d8c99a62b6a6fa0b3c0dc3f761659f62f3f587Marshall Clow#endif
35c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    static_assert(!std::is_integral<T>::value, "");
36c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    static_assert(!std::is_floating_point<T>::value, "");
37c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    static_assert(!std::is_array<T>::value, "");
38c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    static_assert(!std::is_pointer<T>::value, "");
39c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    static_assert(!std::is_lvalue_reference<T>::value, "");
40c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    static_assert(!std::is_rvalue_reference<T>::value, "");
41c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    static_assert(!std::is_member_object_pointer<T>::value, "");
42c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    static_assert(!std::is_member_function_pointer<T>::value, "");
43c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    static_assert(!std::is_enum<T>::value, "");
44c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    static_assert(!std::is_union<T>::value, "");
45c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    static_assert(!std::is_class<T>::value, "");
46c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant    static_assert( std::is_function<T>::value, "");
47c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant}
48c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
4989465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier// Since we can't actually add the const volatile and ref qualifiers once
5089465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier// later let's use a macro to do it.
5189465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier#define TEST_REGULAR(...)                 \
5289465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    test<__VA_ARGS__>();                  \
5389465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    test<__VA_ARGS__ const>();            \
5489465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    test<__VA_ARGS__ volatile>();         \
5589465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    test<__VA_ARGS__ const volatile>()
5689465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier
5789465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier
5889465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier#define TEST_REF_QUALIFIED(...)           \
5989465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    test<__VA_ARGS__ &>();                \
6089465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    test<__VA_ARGS__ const &>();          \
6189465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    test<__VA_ARGS__ volatile &>();       \
6289465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    test<__VA_ARGS__ const volatile &>(); \
6389465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    test<__VA_ARGS__ &&>();               \
6489465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    test<__VA_ARGS__ const &&>();         \
6589465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    test<__VA_ARGS__ volatile &&>();      \
6689465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    test<__VA_ARGS__ const volatile &&>()
6789465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier
687490f53118156f446b61583b7f0af0847b5942d7Marshall Clowstruct incomplete_type;
69c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant
70c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnantint main()
71c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant{
7289465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REGULAR( void () );
7389465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REGULAR( void (int) );
7489465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REGULAR( int (double) );
7589465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REGULAR( int (double, char) );
7689465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REGULAR( void (...) );
7789465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REGULAR( void (int, ...) );
7889465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REGULAR( int (double, ...) );
7989465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REGULAR( int (double, char, ...) );
807490f53118156f446b61583b7f0af0847b5942d7Marshall Clow#if TEST_STD_VER >= 11
8189465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REF_QUALIFIED( void () );
8289465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REF_QUALIFIED( void (int) );
8389465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REF_QUALIFIED( int (double) );
8489465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REF_QUALIFIED( int (double, char) );
8589465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REF_QUALIFIED( void (...) );
8689465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REF_QUALIFIED( void (int, ...) );
8789465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REF_QUALIFIED( int (double, ...) );
8889465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier    TEST_REF_QUALIFIED( int (double, char, ...) );
8989465dce7c16d2108fdf0b64fe6b3e7388c3a24eEric Fiselier#endif
907490f53118156f446b61583b7f0af0847b5942d7Marshall Clow
91211f9a485c4b13c61553d55a7bc662e1506b28fdMarshall Clow//  LWG#2582
927490f53118156f446b61583b7f0af0847b5942d7Marshall Clow    static_assert(!std::is_function<incomplete_type>::value, "");
93c52f43e72dfcea03037729649da84c23b3beb04aHoward Hinnant}
94