std::is_member_pointer
| Defined in header <type_traits> |  |  | 
|---|---|---|
| template< class T > struct is_member_pointer; |  | (since C++11) | 
如果T是指向非静态成员对象的指针,还是指向非静态成员函数的指针,则提供成员常量。value平等true.对于任何其他类型,value是false...
模板参数
| T | - | a type to check | 
|---|
辅助变量模板
| template< class T > inline constexpr bool is_member_pointer_v = is_member_pointer<T>::value; |  | (since C++17) | 
|---|
继承自STD:积分[医]常量
成员常数
| value static | true if T is a member pointer type , false otherwise (public static member constant) | 
|---|
成员函数
| operator bool | converts the object to bool, returns value (public member function) | 
|---|---|
| operator() (C++14) | returns value (public member function) | 
成员类型
| Type | Definition | 
|---|---|
| value_type | bool | 
| type | std::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。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

