1.Boost
:bind
#include
<iostream
>#include
<boost/bind.hpp>
using
namespace
std;using
namespace
boost
;intf(inta,intb= 12)
{return
a+b;}intg(inta,intb,intc){return
a+b+c;}intmain
(intargc
,char
*argv
[]){//通过下面方法调用等价于
f(1,2);
cout
<<"bind(f, 1, 2)() = "
<<bind
(f, 1, 2)() <<
endl
;//同样能够绑定部分参数,例如:下方表示第二个参数传递的是
15cout
<<"bind(f, 12, _1)(15) = "
<<bind
(f, 12,
_1)(15) <<
endl
;//用两个占位符
cout
<<"bind(f, _1, _2)(1, 3) = "
<<bind
(f,_1,_2)(1, 3) <<
endl
;cout
<<"----------"
<<endl
;//引入参数调用的方式
inti= 5 ...


雷达卡


京公网安备 11010802022788号







