How do i write a pointer-to-member-function with std::function?

前端 未结 5 1127
刺人心
刺人心 2020-12-07 15:58

I know how to declare int fn(double) inside of std::function (std::function). I know how to write a pointer-to-member-function (

5条回答
  •  盖世英雄少女心
    2020-12-07 16:20

    If you can use Boost then you can use Boost.Bind. It's easily accomplished like this:

    boost::bind(&MyClass::MemberFunction, pInstance, _1, _2)
    

    Hopefully it's fairly self-explanatory. _1 and _2 are placeholders for parameters you can pass through to the function.

提交回复
热议问题