bind2nd
bind2nd
template <class Operation,class T>
binder2nd <Operation> bind2nd(const Operation&op,const T&x);
返回第二个参数绑定的函数对象
此函数通过将其第二个参数绑定到固定值x,从二元函数对象op构造一元函数对象。bind2nd 返回的函数对象定义了operator(),只需要一个参数。此参数用于调用二进制函数对象op,其中x为第二个参数的固定值。 它的定义与以下行为相同:
template <class Operation, class T>
binder2nd<Operation> bind2nd (const Operation& op, const T& x)
{
return binder2nd<Operation>(op, typename Operation::second_argument_type(x));
}
要将第一个参数绑定到特定值,请参阅bind1st.
参数
op
二进制函数对象派生自binary_function。
x
op的第二个参数的固定值。
返回值
一个等效于op的一元函数对象,但第二个参数始终设置为x。
binder2nd是从unary_function派生的类型。
例
// bind2nd example
#include <iostream>
#include <functional>
#include <algorithm>
using namespace std;
int main () {
int numbers[] = {10,-20,-30,40,-50};
int cx;
cx = count_if ( numbers, numbers+5, bind2nd(less<int>(),0) );
cout << "There are " << cx << " negative elements.\n";
return 0;
}
有3个负面因素。
See also
| bind1st | Return function object with first parameter bound (function template ) |
|---|---|
| binder2nd | Generate function object class with 2nd parameter bound (class template ) |
| unary_function | Unary function object base class (class template ) |
| binary_function | Binary function object base class (class template ) |
bind2nd的更多相关文章
- STL bind1st bind2nd详解
STL bind1st bind2nd详解 先不要被吓到,其实这两个配接器很简单.首先,他们都在头文件<functional>中定义.其次,bind就是绑定的意思,而1st就代表fir ...
- error C2039: “bind2nd”: 不是“std”的成员
VS2012 出现如下错误: error C2039: "bind2nd": 不是"std"的成员 头文件中加上 #include <functi ...
- c++ bind1st 和 bind2nd的用法
std::bind1st 和 std::bind2nd将二元函数转换为一元函数,具体用法参加下面的代码. 代码介绍了两种使用方式,第一种是使用std::less和std::greater,第二种是使用 ...
- 关于标准库中的ptr_fun/binary_function/bind1st/bind2nd
http://www.cnblogs.com/shootingstars/archive/2008/11/14/860042.html 以前使用bind1st以及bind2nd很少,后来发现这两个函数 ...
- Bind2nd源码解析
例:transform(coll1.begin(), coll1.end(), back_inserter(coll2), bind2nd(multiplies<int>(), 10)); ...
- bind1st bind2nd的使用
STL中的函数 bind1st. bind2nd用于将一个二元算子转换成一元算子,需要两个 参数,要转换的bf和一个值v. 参考:http://blog.csdn.net/simahao/articl ...
- 函数适配器bind2nd 、mem_fun_ref 源码分析、函数适配器应用举例
一.适配器 三种类型的适配器: 容器适配器:用来扩展7种基本容器,利用基本容器扩展形成了栈.队列和优先级队列 迭代器适配器:(反向迭代器.插入迭代器.IO流迭代器) 函数适配器:函数适配器能够将仿函数 ...
- not1,not2,bind1st和bind2nd详解
1.引言 bind1st和bind2nd函数用于将一个二元函数对象(binary functor,bf)转换成一元函数对象(unary functor,uf).为了达到这个目的,它们需要两个参数:要转 ...
- STL源码剖析(仿函数/bind2nd)
仿函数(functors)其实就是重载了operator()的对象. 下面简单先看看它的一个例子: #include <iostream> using namespace std; tem ...
- not1,not2,bind1st,bind2nd
例子需要包含头文件 #include <vector> #include <algorithm> #include <functional> bind1st和bin ...
随机推荐
- JDBC-select练习&jdbc工具类&数据库登录案例
一.select练习 1.说明 练习: * 定义一个方法,查询emp表的数据将其封装为对象,然后装载集合,返回. 1. 定义Emp类 2. 定义方法 public List<Emp> fi ...
- python url码转换 chr()码
爬虫生成带搜索词语的网址 1.字符串转为url编码 import urllib poet_name = "李白" url_code_name = urllib.quote(poet ...
- 【Beta】Phylab 测试报告
PhyLab Beta 测试报告 测试中发现的bug Beta阶段新Bug Bug 可能原因 markdown生成的报告可能溢出显示框 表格过长,显示框未设置横向溢出 移动端实验区无法评论 移动端社区 ...
- T-MAX——团队展示
第一次团队博客:百战黄沙穿金甲 基础介绍 这个作业属于哪个课程 2019秋福大软件工程实践Z班 这个作业要求在哪里 团队作业第一次-团队展示 团队名称 T-MAX 这个作业的目标 展现团队成员的风采, ...
- ReentrantLock源码学习总结 (二)
[^]: 以下源码分析基于JDK1.8 ReentrantLock 示例 private ReentrantLock lock = new ReentrantLock(true); public vo ...
- 用Python画一颗特别的心送给她
import numpy as np import matplotlib.pyplot as plt x_coords = np.linspace(-100, 100, 500) y_coords = ...
- kotlin基础 字符串模板
${变量名} var tmp="字符串模板” print("今天学习${tmp}这个知识点")
- spark 监控--WebUi、Metrics System(转载)
转载自:https://www.cnblogs.com/barrenlake/p/4364644.html Spark 监控相关的部分有WebUi 及 Metrics System; WebUi用于展 ...
- JMeter压测上对于并发的认识误区
1.误区 在JMeter压测过程中,我们通常认为1s内100的并发量(即:QPS为100)的设置如下: 此时,没有再添加额外的控制器.上述中的参数设置解释:Number of Threads(user ...
- .netcore项目部署到linux的docker里后,速度异常的慢
.netcore项目部署到linux的docker里后,速度异常的慢,部署在iis下速度非常快. 特别是 接口里再调用其他接口,那速度绝对是蜗牛爬行的速度. 经过几个月的折腾,终于知道是什么问题了: ...