C++ How do you pass a member function into a functor parameter?

前端 未结 2 1681
抹茶落季
抹茶落季 2021-01-23 00:16

I am using TRI DDS - here is the prototype for the function I am trying to call:

template
dds::sub::cond::ReadCondition::Re         


        
2条回答
  •  萌比男神i
    2021-01-23 00:38

    You could use std::bind (see http://en.cppreference.com/w/cpp/utility/functional/bind)

    dds::sub::cond::ReadCondition rc(*mp_reader,
                                     dds::sub::status::DataState::any(),
                                     std::bind(&MyClass::do_stuff, this));
    

    See also How to directly bind a member function to an std::function in Visual Studio 11?

提交回复
热议问题