Calling a lambda expression multiple times

后端 未结 2 1702
隐瞒了意图╮
隐瞒了意图╮ 2021-02-15 15:07

I\'m trying the lambda-expressions from the new standard, and still don\'t understand them quite well.

Let\'s say I have a lambda somewhere in my code, e.g. in my main:<

2条回答
  •  南笙
    南笙 (楼主)
    2021-02-15 16:12

    auto lambda = [](int x, int y)->float
        {
            return static_cast(x) / static_cast(y);
        };
    // code
    // call lambda
    std::cout << lambda(1, 2) << std::endl;
    

提交回复
热议问题