草庐IT

simple_bind_s

全部标签

c++ - 我可以将( boost )绑定(bind)与功能模板一起使用吗?

是否可以使用(boost)bind将参数绑定(bind)到函数模板?//Defineatemplatefunction(justasillyexample)templateARG1FCall2Templ(ARG1arg1,ARG2arg2){returnarg1+arg2;}//trytobindthistemplatefunction(andcallit)...boost::bind(FCall2Templ,42,56)();//Thisworksboost::bind(FCall2Templ,42,56)();//Thisemits5pagesoferrormessagesonVS

c++ - 我可以将( boost )绑定(bind)与功能模板一起使用吗?

是否可以使用(boost)bind将参数绑定(bind)到函数模板?//Defineatemplatefunction(justasillyexample)templateARG1FCall2Templ(ARG1arg1,ARG2arg2){returnarg1+arg2;}//trytobindthistemplatefunction(andcallit)...boost::bind(FCall2Templ,42,56)();//Thisworksboost::bind(FCall2Templ,42,56)();//Thisemits5pagesoferrormessagesonVS

c++ - 如何在 C++ 中绑定(bind)构造函数?

无需过多解释。以下代码不言而喻:structX{X(intn){}};intmain(){std::vectorsrc;std::vectordest;//BelowisnotvalidincurrentC++,butthatisjustwhatIwant.transform(src.begin(),src.end(),back_insert(dest),std::bind(&X::X,_1));}构造函数接受一些参数并返回构造函数类的对象。构造函数看起来像一个函数,行为像一个函数,并且完全是一个函数。所以,我认为std::bind应该统一对待构造函数和其他可调用对象。但是,如何扩展函

c++ - 如何在 C++ 中绑定(bind)构造函数?

无需过多解释。以下代码不言而喻:structX{X(intn){}};intmain(){std::vectorsrc;std::vectordest;//BelowisnotvalidincurrentC++,butthatisjustwhatIwant.transform(src.begin(),src.end(),back_insert(dest),std::bind(&X::X,_1));}构造函数接受一些参数并返回构造函数类的对象。构造函数看起来像一个函数,行为像一个函数,并且完全是一个函数。所以,我认为std::bind应该统一对待构造函数和其他可调用对象。但是,如何扩展函

c++ - 使用带有 libcxx 的套接字函数 bind() 编译代码失败

我正在使用新的libcxx库,并且我有一个调用套接字函数的代码bind().问题是当我输入usingnamespacestd;编译器给了我以下代码的错误:intres=bind(sockfd,(structsockaddr*)&myAddr,sizeof(myAddr));使用clang(svnbuild)的错误:error:noviableconversionfrom'__bind'to'int'intres=bind(sockfd,(structsockaddr*)&myAddr,sizeof(myAddr));我认为问题在于usingnamespacestd;带函数std::bi

c++ - 使用带有 libcxx 的套接字函数 bind() 编译代码失败

我正在使用新的libcxx库,并且我有一个调用套接字函数的代码bind().问题是当我输入usingnamespacestd;编译器给了我以下代码的错误:intres=bind(sockfd,(structsockaddr*)&myAddr,sizeof(myAddr));使用clang(svnbuild)的错误:error:noviableconversionfrom'__bind'to'int'intres=bind(sockfd,(structsockaddr*)&myAddr,sizeof(myAddr));我认为问题在于usingnamespacestd;带函数std::bi

c++ - 嵌套绑定(bind)表达式

这是mypreviousquestion的后续问题.#includeintfoo(void){return2;}classbar{public:intoperator()(void){return3;};intsomething(inta){returna;};};templateautofunc(C&&c)->decltype(c()){returnc();}templateintdoit(C&&c){returnc();}templatevoidfunc_wrapper(C&&c){func(std::bind(doit,std::forward(c)));}intmain(int

c++ - 嵌套绑定(bind)表达式

这是mypreviousquestion的后续问题.#includeintfoo(void){return2;}classbar{public:intoperator()(void){return3;};intsomething(inta){returna;};};templateautofunc(C&&c)->decltype(c()){returnc();}templateintdoit(C&&c){returnc();}templatevoidfunc_wrapper(C&&c){func(std::bind(doit,std::forward(c)));}intmain(int

c++ - 使用 static const + const 作为数组绑定(bind)

我正在做这样的事情类.hpp:classClass{private:staticconstunsignedintarraySize;intar[arraySize+2];};类.cpp:#includeconstunsignedintarraySize=384;编译器(q++,基于g++的QNX操作系统的c++编译器)给了我error:arrayboundisnotanintegerconstant在编译包含Class.hpp的单元时(不是在编译Class.cpp时)。为什么这不起作用?我知道静态const成员可以用作数组绑定(bind),由C++标准保证(参见thisanwser)。

c++ - 使用 static const + const 作为数组绑定(bind)

我正在做这样的事情类.hpp:classClass{private:staticconstunsignedintarraySize;intar[arraySize+2];};类.cpp:#includeconstunsignedintarraySize=384;编译器(q++,基于g++的QNX操作系统的c++编译器)给了我error:arrayboundisnotanintegerconstant在编译包含Class.hpp的单元时(不是在编译Class.cpp时)。为什么这不起作用?我知道静态const成员可以用作数组绑定(bind),由C++标准保证(参见thisanwser)。