定义于头文件
<type_traits>
|
||
template< class T >
struct is_member_function_pointer; |
(C++11 起) | |
检查 T
是否为非静态成员函数指针。若 T
为非静态成员函数指针类型,则提供等于 true 的成员常量 value
。否则, value
等于 false 。
目录 |
T | - | 要检查的类型 |
template< class T >
inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<T>::value; |
(C++17 起) | |
value
[静态]
|
若 T 是成员函数指针类型则为 true ,否则为 false (公开静态成员常量) |
operator bool
|
转换对象为 bool ,返回 value (公开成员函数) |
operator()
(C++14)
|
返回 value (公开成员函数) |
类型 | 定义 |
value_type
|
bool
|
type
|
std::integral_constant<bool, value> |
template< class T > struct is_member_function_pointer_helper : std::false_type {}; template< class T, class U> struct is_member_function_pointer_helper<T U::*> : std::is_function<T> {}; template< class T > struct is_member_function_pointer : is_member_function_pointer_helper< std::remove_cv_t<T> > {}; |
#include <type_traits> class A { public: void member() { } }; int main() { // 在编译时失败,若 A::member 是数据成员而非函数 static_assert(std::is_member_function_pointer<decltype(&A::member)>::value, "A::member is not a member function."); }
(C++11)
|
检查类型是否为指针类型 (类模板) |
(C++11)
|
检查类型是否为指向非静态成员对象的指针 (类模板) |
(C++11)
|
检查类型是否为指向非静态成员函数或对象的指针类型 (类模板) |