One option is to just use lambda:
class A { private: double m_x, m_y; public: A(double x, double y): m_x {x} { m_y = extF(m_x, y, [&](double d){ return intF(d);}); } double intF(double x) { return 2*x; } };
Another option is to use lambda and std::mem_fn (excluding the rest of your class code):
A(double x, double y): m_x {x} { auto fn = std::mem_fn(&A::intF); m_y = extF(m_x, y, [&](double d) {return fn(this, d);}); }
And finally, you can get rid of lambda if the bind parameter of the member function pointer object is:
A(double x, double y): m_x {x} { auto fn1 = std::bind(std::mem_fn(&A::intF), this, std::placeholders::_1); m_y = extF(m_x, y, fn1); }
All of this also works with persistent member functions.
source share