How to use lambda functions with boost::bind/std::bind in VC++ 2010?

后端 未结 3 2073
太阳男子
太阳男子 2021-02-07 09:25

I have some lambda functions which I want to bind using either boost::bind or std::bind. (Don\'t care which one, as long as it works.) Unfortunately both of them give me differe

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-07 09:48

    You need to manually specify the return type:

    boost::bind(f)();
    boost::bind(f2, 13)();
    

    You can also write yourself a template-function to deduce the return type automagically using Boost.FunctionTypes to inspect your lambda's operator(), if you don't like to explicitly tell bind.

提交回复
热议问题