Namespaces
Variants

std:: is_member_function_pointer

From es.cppreference.net
Metaprogramming library
Type traits
Type categories
(C++11)
(C++11) ( DR* )
is_member_function_pointer
(C++11)
Type properties
(C++11)
(C++11)
(C++14)
(C++11) (deprecated in C++26)
(C++11) ( until C++20* )
(C++11) (deprecated in C++20)
(C++11)
Type trait constants
Metafunctions
(C++17)
Supported operations
Relationships and property queries
Type modifications
Type transformations
(C++11) (deprecated in C++23)
(C++11) (deprecated in C++23)
(C++11)
(C++11) ( until C++20* ) (C++17)

Compile-time rational arithmetic
Compile-time integer sequences
Definido en el encabezado <type_traits>
template < class T >
struct is_member_function_pointer ;
(desde C++11)

std::is_member_function_pointer es un UnaryTypeTrait .

Comprueba si T es un puntero a función miembro no estática. Proporciona la constante miembro value que es igual a true , si T es un tipo puntero a función miembro no estática. De lo contrario, value es igual a false .

Si el programa añade especializaciones para std::is_member_function_pointer o std::is_member_function_pointer_v , el comportamiento es indefinido.

Contenidos

Parámetros de plantilla

T - un tipo a verificar

Plantilla de variable auxiliar

template < class T >

constexpr bool is_member_function_pointer_v =

is_member_function_pointer < T > :: value ;
(desde C++17)

Heredado de std:: integral_constant

Constantes miembro

value
[static]
true si T es un tipo de puntero a función miembro, false en caso contrario
(constante miembro pública estática)

Funciones miembro

operator bool
convierte el objeto a bool , devuelve value
(función miembro pública)
operator()
(C++14)
devuelve value
(función miembro pública)

Tipos miembro

Tipo Definición
value_type bool
type std:: integral_constant < bool , value >

Implementación posible

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<typename std::remove_cv<T>::type> {};

Ejemplo

#include <type_traits>
class A
{
public:
    void member() {}
};
int main()
{
    // falla en tiempo de compilación si A::member es un miembro de datos y no una función
    static_assert(std::is_member_function_pointer<decltype(&A::member)>::value,
                  "A::member is not a member function."); 
}

Véase también

(C++11)
verifica si un tipo es un tipo puntero
(class template)
verifica si un tipo es un puntero a miembro de objeto no estático
(class template)
verifica si un tipo es un puntero a miembro de función u objeto no estático
(class template)