bind function adapter (included <functional>)

Introduce:

bind(op, args, …)  Binds args to op

Simple Code

int>(), std::placeholders::_1, 10);
cout<<pfn(7); // 17

Note that bind() internally copies passed arguments. To let the function object use a reference to a passed argument, use ref() or cref()

int i = 1;
prf(i);
cout<<i<<endl;// 2

For member function
return 0;
}
Note: the member funciton should be const function.
Note that you can also pass pointers to objects and even smart pointers to bind():
)};
for_each(vps.begin(), vps.end(), bind(&BindPerson::Print, _1));


相关文章:

  • 2022-12-23
  • 2021-07-06
  • 2021-10-14
  • 2022-02-11
  • 2021-11-06
  • 2021-07-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案