◐ Shell
clean mode source ↗

std::is_member_function_pointer - cppreference.com

提供: cppreference.com

<tbody> </tbody>

template< class T > struct is_member_function_pointer;

(C++11以上)

T が非静的メンバ関数ポインタかどうか調べます。 T が非静的メンバ関数ポインタ型であれば、 true に等しいメンバ定数 value が提供されます。 そうでなければ、 valuefalse に等しくなります。

is_member_function_pointer または is_member_function_pointer_v (C++17以上) に対して特殊化を追加するプログラムは未定義です。

テンプレート引数

ヘルパー変数テンプレート

<tbody> </tbody>

template< class T > inline constexpr bool is_member_function_pointer_v = is_member_function_pointer<T>::value;

(C++17以上)

std::integral_constant から継承

メンバ定数

T がメンバ関数ポインタ型ならば true、そうでなければ false
(パブリック静的メンバ定数)

メンバ関数

オブジェクトを bool に変換します。 value を返します
(パブリックメンバ関数)
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()
{
    // 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."); 
}

関連項目