跳到主要内容

std::map value_compare

class value_compare;

value_compare 是一个函数对象,它通过比较键值对的第一个组件来比较 value_type 类型的对象(键值对)。

成员类型

公有
类型
定义
公有result_type (C++17 中已弃用) (C++20 中已移除)bool
公有first_argument_type (C++17 中已弃用) (C++20 中已移除)value_type
公有second_argument_type (C++17 中已弃用) (C++20 中已移除)value_type
这些成员类型通过公开继承 std::binary_function<value_type, value_type, bool> 获得。

受保护成员对象

保护Compare comp存储的比较器

成员函数

保护(构造函数)构造一个新的 value_compare 对象
protected:
value_compare( Compare c );

将比较器的内部实例初始化为 c

参数

  • c - 要赋值的比较器
公有operator()比较两个 value_type 类型的值
// Const version only
bool operator()( const value_type& lhs, const value_type& rhs ) const;

通过调用存储的比较器来比较 lhs.firstrhs.first

参数

  • lhs, rhs - 要比较的值

返回值

comp(lhs.first, rhs.first).

异常

可能会抛出实现定义的异常。

本文源自此 CppReference 页面。它可能为了改进或编辑偏好而被修改。单击“编辑此页面”查看本文档的所有更改。
悬停查看原始许可证。

std::map value_compare

class value_compare;

value_compare 是一个函数对象,它通过比较键值对的第一个组件来比较 value_type 类型的对象(键值对)。

成员类型

公有
类型
定义
公有result_type (C++17 中已弃用) (C++20 中已移除)bool
公有first_argument_type (C++17 中已弃用) (C++20 中已移除)value_type
公有second_argument_type (C++17 中已弃用) (C++20 中已移除)value_type
这些成员类型通过公开继承 std::binary_function<value_type, value_type, bool> 获得。

受保护成员对象

保护Compare comp存储的比较器

成员函数

保护(构造函数)构造一个新的 value_compare 对象
protected:
value_compare( Compare c );

将比较器的内部实例初始化为 c

参数

  • c - 要赋值的比较器
公有operator()比较两个 value_type 类型的值
// Const version only
bool operator()( const value_type& lhs, const value_type& rhs ) const;

通过调用存储的比较器来比较 lhs.firstrhs.first

参数

  • lhs, rhs - 要比较的值

返回值

comp(lhs.first, rhs.first).

异常

可能会抛出实现定义的异常。

本文源自此 CppReference 页面。它可能为了改进或编辑偏好而被修改。单击“编辑此页面”查看本文档的所有更改。
悬停查看原始许可证。