unary_function
binary_function
一元和二元函数.
场景:
1.C++算法库里经常出现unary_function和binary_function类型,比如sort,count_if,find_if,或者std::map的构造函数等,这是用来对元素进行比较用的类型.
template <class Arg, class Result> struct unary_function;
template <class Arg1, class Arg2, class Result> struct binary_function;
以下是从cplusplus.com摘录的说明:
二元函数转换为一元函数 bind2nd
http://www.cplusplus.com/reference/functional/bind2nd/?kw=bind2nd
template <class Operation, class T>
binder2nd<Operation> bind2nd (const Operation& op, const T& x);
Return function object with second parameter b

本文介绍了C/C++标准库中的unary_function和binary_function,这两种函数常用于算法如sort、count_if、find_if以及std::map的构造中,作为元素比较的工具。
订阅专栏 解锁全文
321

被折叠的 条评论
为什么被折叠?



