#include<functional>
int foo(int x, int y)
{
return x+y;
}
int main()
{
//定义一个返回值bool,具有一个int参数的函数
function<bool(int)> inner = [&](int x) {
//函数定义...
return true;
};
//直接调用
inner(1);
//直接赋值
function<int(int, int)> rename = foo;
rename(1, 1);
}
function相当于一个类或类型(比如vector),表示函数的封装
https://en.cppreference.com/w/cpp/header/functional