194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow//===----------------------------------------------------------------------===//
294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow//
394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow//                     The LLVM Compiler Infrastructure
494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow//
594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow// This file is dual licensed under the MIT and the University of Illinois Open
694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow// Source Licenses. See LICENSE.TXT for details.
794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow//
894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow//===----------------------------------------------------------------------===//
994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
1094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow// type_traits
1194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
1294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow// is_member_pointer
1394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
1494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow#include <type_traits>
1555d741c32e72234c022c728f24ccafb80ab8b485Marshall Clow#include <cstddef>        // for std::nullptr_t
1694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow#include "test_macros.h"
1794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
1894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowtemplate <class T>
1994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowvoid test_is_member_pointer()
2094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow{
2194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_member_pointer<T>::value, "");
2294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_member_pointer<const T>::value, "");
2394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_member_pointer<volatile T>::value, "");
2494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_member_pointer<const volatile T>::value, "");
2594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow#if TEST_STD_VER > 14
2694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_member_pointer_v<T>, "");
2794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_member_pointer_v<const T>, "");
2894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_member_pointer_v<volatile T>, "");
2994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert( std::is_member_pointer_v<const volatile T>, "");
3094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow#endif
3194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow}
3294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
3394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowtemplate <class T>
3494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowvoid test_is_not_member_pointer()
3594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow{
3694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_member_pointer<T>::value, "");
3794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_member_pointer<const T>::value, "");
3894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_member_pointer<volatile T>::value, "");
3994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_member_pointer<const volatile T>::value, "");
4094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow#if TEST_STD_VER > 14
4194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_member_pointer_v<T>, "");
4294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_member_pointer_v<const T>, "");
4394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_member_pointer_v<volatile T>, "");
4494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    static_assert(!std::is_member_pointer_v<const volatile T>, "");
4594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow#endif
4694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow}
4794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
4894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowclass Empty
4994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow{
5094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow};
5194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
5294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowclass NotEmpty
5394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow{
5494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    virtual ~NotEmpty();
5594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow};
5694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
5794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowunion Union {};
5894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
5994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowstruct bit_zero
6094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow{
6194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    int :  0;
6294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow};
6394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
6494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowclass Abstract
6594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow{
6694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    virtual ~Abstract() = 0;
6794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow};
6894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
6994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowenum Enum {zero, one};
707490f53118156f446b61583b7f0af0847b5942d7Marshall Clowstruct incomplete_type;
7194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
7294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowtypedef void (*FunctionPtr)();
7394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
7494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
7594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clowint main()
7694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow{
7794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_member_pointer<int Abstract::*>();
7894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_member_pointer<double NotEmpty::*>();
7994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_member_pointer<FunctionPtr Empty::*>();
8094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_member_pointer<void (Empty::*)()>();
8194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow
8294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<std::nullptr_t>();
8394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<void>();
8494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<int>();
8594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<int&>();
8694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<int&&>();
8794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<int*>();
8894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<double>();
8994611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<const int*>();
9094611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<char[3]>();
9194611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<char[]>();
9294611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<Union>();
9394611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<Enum>();
9494611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<FunctionPtr>();
9594611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<Empty>();
9694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<bit_zero>();
9794611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<NotEmpty>();
9894611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow    test_is_not_member_pointer<Abstract>();
997490f53118156f446b61583b7f0af0847b5942d7Marshall Clow    test_is_not_member_pointer<incomplete_type>();
1002c477cb41afd22162ab5ac671eea3cb78cdc2d6cEric Fiselier
1012c477cb41afd22162ab5ac671eea3cb78cdc2d6cEric Fiselier#if TEST_STD_VER >= 11
1022c477cb41afd22162ab5ac671eea3cb78cdc2d6cEric Fiselier  test_is_member_pointer<int (Empty::*)(int, ...) const>();
1032c477cb41afd22162ab5ac671eea3cb78cdc2d6cEric Fiselier  test_is_member_pointer<int (Empty::*)(int, long, long) const noexcept>();
1042c477cb41afd22162ab5ac671eea3cb78cdc2d6cEric Fiselier  test_is_member_pointer<int (Empty::*)() & noexcept>();
1052c477cb41afd22162ab5ac671eea3cb78cdc2d6cEric Fiselier#endif
10694611a888b69dabe99f8fe30867d0ebd78854759Marshall Clow}
107