Lambda as function parameter

后端 未结 2 1316
北海茫月
北海茫月 2020-12-12 15:09

What\'s the notation for declaring a lambda variable, or function parameter, without the use of auto or templates? Is there any way to do so? Or does the compil

2条回答
  •  执念已碎
    2020-12-12 15:29

    You can use a polymorphic wrapper for a function object. For example:

    #include 
    
    std::function f = [](double a, double b) { return a*b };
    

提交回复
热议问题