We recommend using Visual Studio 2017

mem_fun_ref_t Class


The latest version of this topic can be found at mem_fun_ref_t Class.

An adapter class that allows a non_const member function that takes no arguments to be called as a unary function object when initialized with a reference argument.

template <class Result, class Type>
class mem_fun_ref_t : public unary_function<Type, Result> {
    explicit mem_fun_ref_t(
    Result (Type::* _Pm)());

    Result operator()(Type& left) const;



A pointer to the member function of class Type to be converted to a function object.

The object that the _Pm member function is called on.

An adaptable unary function.

The template class stores a copy of _Pm, which must be a pointer to a member function of class Type, in a private member object. It defines its member function operator() as returning ( left.* _Pm)( ).

The constructor of mem_fun_ref_t is not usually used directly; the helper function mem_fun_ref is used to adapt member functions. See mem_fun_ref for an example of how to use member function adaptors.

Header: <functional>

Namespace: std

Thread Safety in the C++ Standard Library
Standard Template Library