函数适配器:bind2nd
来源:互联网 发布:华为网络面试 知乎 编辑:程序博客网 时间:2024/06/11 03:48
1.bind2nd使用
2.bind2nd源码
template<class Operation, class T>
inline binder2nd<Operation> bind2nd(const Operation& op, const T& x) {typedef typename Operation::second_argument_type arg2_type;
return binder2nd<Operation>(op, arg2_type(x));
}
template<class Operation>
class binder2nd
: public unary_function<typename Operation::first_argument_type,
typename Operation::result_type> {
protected:
Operation op;
typename Operation::second_argument_type value;
public:
binder2nd(const Operation& x,
const typename Operation::second_argument_type& y)
:op(x), value(y) {
}
typename Operation::result_type
operator(const typename Operation::first_argument_type& x) const {
return op(x,value);
}
};
template<class InputIterator, class Predicate>
typename iterator_traits<InputIterator>::difference_type
count_if(InputIterator first, InputIteratorlast,
Predicate pred) {
typename
iterator_traits<InputIterator>::difference_type n = 0;
for(;first != last; ++ first) {
if(pred(*first))
++n;
return n;
}
}
阅读全文
1 0
- 函数适配器bind2nd
- 函数适配器:bind2nd
- 函数对象适配器 bind2nd bind1st
- C++之STL(九):函数适配器bind2nd 、mem_fun_ref 源码分析、函数适配器应用举例
- STL(九):函数适配器bind2nd 、mem_fun_ref 源码分析、函数适配器应用举例
- 从零开始学C++之STL(九):函数适配器bind2nd 、mem_fun_ref 源码分析、函数适配器应用举例
- 从零开始学C++之STL(九):函数适配器bind2nd 、mem_fun_ref 源码分析、函数适配器应用举例
- 关于函数适配器less< Type>以及bind1st和bind2nd的使用
- bind1st和bind2nd函数
- 理解bind1st和bind2nd函数
- 二元函数与bind1st/bind2nd
- bind1st与bind2nd函数解析
- bind1st与bind2nd函数解析
- bind2nd
- 函数bind1st 和 bind2nd 的说明
- 【STL】bind1st与bind2nd函数解析
- 【STL】bind1st与bind2nd函数解析
- C++值函数绑定器bind2nd
- Lua的类Class实现
- 微信小程序 运行机制 框架原理(自我学习记录)
- ZIP文件解压(java)
- 自定义adapter
- Android View的绘制流程
- 函数适配器:bind2nd
- java中如何正确处理异常
- 学习笔记之Linux网络编程入门
- Codeforces Round #417 (Div. 2) B. Sagheer, the Hausmeister(动态规划)
- Caffe——python接口学习(1):生成配置文件
- python 多线程 —— threading.Threading()
- Kotlin基本语法
- Lua类函数的几种构造方法
- Android学习笔记ContentProvider