C++
应用 | Utilities

std::is_member_pointer

STD::是[医]成员[医]指针

Defined in header
template< class T > struct is_member_pointer;(since C++11)

如果T是指向非静态成员对象的指针,还是指向非静态成员函数的指针,则提供成员常量。value平等true.对于任何其他类型,valuefalse...

模板参数

T-a type to check

辅助变量模板

template< class T > inline constexpr bool is_member_pointer_v = is_member_pointer::value;(since C++17)

继承自STD:积分[医]常量

成员常数

value statictrue if T is a member pointer type , false otherwise (public static member constant)

成员函数

operator boolconverts the object to bool, returns value (public member function)
operator() (C++14)returns value (public member function)

成员类型

TypeDefinition
value_typebool
typestd::integral_constant<bool, value>

可能的实施

模板<class T>结构是[医]成员[医]指针[医]助手:std::false[医]类型{};模板<类T,类U>结构是[医]成员[医]指针[医]助手<T U::%2A>:STD::真[医]类型{};模板<class T>结构是[医]成员[医]指针:是[医]成员[医]指针[医]助手<type Name STD::Remove[医]CV<T>*类型>{};

*。

二次

#include <iostream> #include <type_traits> int main() { class cls {}; std::cout << (std::is_member_pointer<int(cls::*)>::value ? "T is member pointer" : "T is not a member pointer") << '\n'; std::cout << (std::is_member_pointer<int>::value ? "T is member pointer" : "T is not a member pointer") << '\n'; }

二次

产出:

二次

T is member pointer T is not a member pointer

二次

另见

is_pointer (C++11)checks if a type is a pointer type (class template)
is_member_object_pointer (C++11)checks if a type is a pointer to a non-static member object (class template)
is_member_function_pointer (C++11)checks if a type is a pointer to a non-static member function (class template)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/type/is[医]成员[医]指针