【发布时间】:2018-02-23 10:43:13
【问题描述】:
我可以使用 lambda 绑定私有成员函数。我正在努力使用std::bind 编写等效的内容。这是我的尝试,但无法编译。
#include <functional>
class A {
private:
double foo(double x, double y);
public:
A();
std::function<double(double,double)> std_function;
};
A::A() {
// This works:
//std_function = [this](double x, double y){return foo(x,y);};
std_function = std::bind(&A::foo,this,std::placeholders::_1));
}
【问题讨论】: