c++ Function member pointer

前端 未结 4 1990
伪装坚强ぢ
伪装坚强ぢ 2021-01-29 09:43

I have read several posts about this, but can\'t seem to find exactly what i am looking for with example code if anyone could give me some help i would highly appreciate it.

4条回答
  •  感动是毒
    2021-01-29 10:09

    The simple solution is using type erasure on the function/function pointer type, for which the easier way is just using std::function<>:

    std::list;
    

    Then you can initialize the function objects with either a free function or a member function (by means of std::bind to bind the member-function with an object on which to call it) or even function objects (types that offer an operator()).

提交回复
热议问题