const_mem_fun1_ref_t 类

一种适配器类,在使用引用自变量进行初始化的情况下,该类允许将仅带一个自变量的 const 成员函数作为二元函数对象调用。 在 C++11 中已弃用,在 C++17 中已移除。

语法

template <class Result, class Type, class Arg>
    class const_mem_fun1_ref_t
        : public binary_function<Type, Arg, Result>
{
    explicit const_mem_fun1_ref_t(Result (Type::* Pm)(Arg) const);
    Result operator()(const Type& left, Arg right) const;
};

参数

Pm
一个指针,指向要转换为函数对象的 Type 类成员函数。

left
要在其上调用 Pm 成员函数的 const 对象。

right
提供给 Pm 的参数

返回值

一个自适应二元函数。

注解

类模板存储 _Pm 的副本,它必须是专用成员对象中指向类 Type 的成员函数的指针。 它将其成员函数 operator() 定义为返回 (left.* Pm)(right) const

示例

通常不直接使用 const_mem_fun1_ref_t 的构造函数;helper 函数 mem_fun_ref 用于调整成员函数。 有关如何使用成员函数适配器的示例,请参阅 mem_fun_ref