C++(11):bind

bind函数可以将既有函数的参数绑定起来,从而生成一个函数对象:

#include 
#include 
using namespace std;

void func1(int d)
{
    cout<<__func__<<" "<

如果函数有多个参数,可以只绑定部分参数,然后通过placeholders::_1标示调用函数对象时的参数占位符:

#include 
#include 
using namespace std;

void func1(int d1, int d2)
{
    cout<<__func__<<" "<

你可能感兴趣的:(C/C++,c++)