C++ Function Callbacks: Cannot convert from a member function to a function signature

后端 未结 6 525
盖世英雄少女心
盖世英雄少女心 2020-11-29 12:22

I\'m using a 3rd party library that allows me to register callbacks for certain events. The register function looks something like this. It uses the Callback signature.

6条回答
  •  忘掉有多难
    2020-11-29 13:04

    Since you are using C++, why not make the callback a functor object? Then you can use std::mem_fun.

    Edit: Seems std::mem_fun has been deprecated in the latest C++11 standard. So std::function might be a better solution if you have a new compiler.

    See this SO question for hints about using it.

提交回复
热议问题