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 ...
随机推荐
- 使用s3-sftp-proxy 暴露minio s3 数据为sftp 访问
尽管s3 很不错,但是ftp 也有自己存在的价值,以下是一个简单的通过s3-sftp-proxy 暴露minio s3 数据为ftp 的访问方式 环境准备 docker-compose 文件 vers ...
- 正睿2019省选附加赛 Day10 (这篇其实已经都咕咕了...)
目录 2019.3.13 A.算算算(二项式定理 斯特林数) B.买买买 C.树树树 2019.3.13 比赛链接 A.算算算(二项式定理 斯特林数) 题目链接 \(x^k\)可以用二项式定理展开,需 ...
- python爬虫出现ProxyError: HTTPSConnectionPool错误
在今天刚刚打开pycharm运行爬虫时,发现所有的爬虫都不能运行,会出现如下的错误: 错误出现的主要原因是;代理错误(其实自己根本没有设置代理) 解决方法: 在网上查阅了许多类似的错误解决方法,试过后 ...
- 各软件发布版本简写(Alpha Beta RC GA DMR)
Alpha:是内部测试版,一般不向外部发布,会有很多Bug.一般只有测试人员使用. Beta:也是测试版,这个阶段的版本会一直加入新的功能.在Alpha版之后推出. RC:(Release Candi ...
- windows内核代码之进程操作
[toc] 一丶简介 整理一下windows内核中.常用的代码.这里只整理下进程的相关代码. 二丶 windows内核之遍历进程 内核中记录进程的结构体是EPROCESS结构.所以只需要遍历这个结构即 ...
- html内获取当前文件路径,页面获取当前路径
function getRealPath(){ var curWwwPath = window.document.location.href; var pathName = window.docume ...
- 初识RSA
基础知识:http://www.guideep.com/read?guide=5676830073815040# python实现:https://blog.csdn.net/bian_h_f6127 ...
- Seq2Seq模型 与 Attention 策略
Seq2Seq模型 传统的机器翻译的方法往往是基于单词与短语的统计,以及复杂的语法结构来完成的.基于序列的方式,可以看成两步,分别是 Encoder 与 Decoder,Encoder 阶段就是将输入 ...
- 主题模型(LDA)(一)--通俗理解与简单应用
版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/qq_39422642/article/de ...
- (转)plsql11 x64 安装和配置 解决OCI: not initialized
跟帖子一样,安装了pl/sql ,设置了oci.dll 以及 TNS_ADMIN,加入path后不能显示数据库连接. 安装 microsoft visual c++ redistributable 2 ...