std::is_member_function_pointer
提供: cppreference.com
ヘッダ <type_traits> で定義 | ||
template<class T > struct is_member_function_pointer; | (C++11以上) | |
T
が非静的メンバ関数ポインタかどうか調べます。 T
が非静的メンバ関数ポインタ型であれば、 true に等しいメンバ定数 value
が提供されます。 そうでなければ、 value
は false に等しくなります。
is_member_function_pointer
または is_member_function_pointer_v
(C++17以上) に対して特殊化を追加するプログラムは未定義です。
目次 |
[編集]テンプレート引数
T | - | 調べる型 |
[編集] ヘルパー変数テンプレート
template<class T > inlineconstexprbool is_member_function_pointer_v = is_member_function_pointer<T>::value; | (C++17以上) | |
std::integral_constant から継承
メンバ定数
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>>{}; |
[編集]例
Run this code
#include <type_traits> class A {public:void member(){}}; int main(){// fails at compile time if A::member is a data member and not a function static_assert(std::is_member_function_pointer<decltype(&A::member)>::value, "A::member is not a member function.");}
[編集]関連項目
(C++11) | 型がポインタ型かどうか調べます (クラステンプレート) |
(C++11) | 型が非静的メンバオブジェクトへのポインタかどうか調べます (クラステンプレート) |
(C++11) | 型が非静的メンバ関数または非静的メンバオブジェクトかどうか調べます (クラステンプレート) |