std::bind1st与std::bind2nd的区别
来源:互联网 发布:java变量 编辑:程序博客网 时间:2024/06/05 11:36
bind1st(const Fn2& Func,const Ty& left); //1st指:传进来的参数应该放左边,也就是第1名
bind2nd(const Fn2& Func,const Ty& right); //2nd指:传进来的参数应该放右边,也就是第2名
transform(coll.begin(),coll.end(),ostream_iterator<int>(cout,""),
bind1st(foPow<float,int>(),3))
bind2nd(foPow<float,int>(),3))
// 移除所有小于100的元素
arr.erase( std::remove_if( arr.begin(), arr.end(),
std::bind2nd( std::less< int>(), 100)), arr.end());
bind2nd(const Fn2& Func,const Ty& right); //2nd指:传进来的参数应该放右边,也就是第2名
//例子1:
transform(coll.begin(),coll.end(),ostream_iterator<int>(cout,""),
bind1st(foPow<float,int>(),3))
结果:3 9 27 81 243 729 2187 6561 19683
解释:把参数3放在左边,即3的几次方。
bind2nd(foPow<float,int>(),3))
结果: 1 8 27 64 125 216 343 512 729
解释:把参数3放在右边,即?的3次方。
//例子2:
// 移除所有大于100的元素
arr.erase( std::remove_if( arr.begin(), arr.end(),
std::bind1st( std::less< int>(), 100)), arr.end());
解释:把参数100放在左边,即100<。
// 移除所有小于100的元素
arr.erase( std::remove_if( arr.begin(), arr.end(),
std::bind2nd( std::less< int>(), 100)), arr.end());
解释:把参数100放在右边,即<100。
0 0
- std::bind1st与std::bind2nd的区别
- std::bind1st std::bind2nd boost::bind
- std::mem_fun vs std::mem_fn, std::bind1st/std::bind2nd vs std::bind
- bind1st 和 bind2nd的区别
- STL中bind1st和bind2nd的区别
- bind1st bind2nd的使用
- bind1st bind2nd的使用
- bind1st bind2nd的使用
- bind1st bind2nd的使用
- 二元函数与bind1st/bind2nd
- bind1st与bind2nd函数解析
- bind1st与bind2nd函数解析
- (转)bind1st、bind2nd的使用
- std::cerr与std::cout区别
- bind1st & bind2nd
- Matlab rms与std的区别
- __sso_string与std::string的区别
- STL binder1st binder2nd bind1st bind2nd区别
- 保護你的隱私,從 PGP 開始!
- Windows安装Apache后的一些设置
- leetcode 1: Two Sum
- springMVC 的实现
- Android拍照得到的照片旋转了90度
- std::bind1st与std::bind2nd的区别
- Centos 简单的安全设置
- 分布式系统应用现状
- SpringMVC在Tomcat下报异常
- 主动通知Android系统图库进行更新
- 打印一个集合的幂集C++实现
- Unix Ware平台上SIGCLD重复发送解决办法
- 欢迎使用CSDN-markdown编辑器
- cocos2dlua-导演