C++ From Scratch: Lambdas

preview_player
Показать описание
In this video we learn about the basics of lambdas and lambda expressions in C++!

Рекомендации по теме
Комментарии
Автор

Thank you, Nick. You are brilliant person.I believe your course and effort delivered will only boost the "renaissance" of C++. Extraordinary work, "clear" and consistent. The Lambda function is extremely powerful, especially for algorithms and containers. For all of you who want to extend this particular knowledge, I really recommend the book: Lambda Expressions in Modern C++ by Bartlomiej Filipek. Thank you Nick and have a nice day!

markusbuchholz
Автор

Instead of passing [divisor=10] in captures, it is as good as writing "return dividend %10 == 0" right ?

pradeepkumarreddykondreddy
Автор

I don't get it. when is the "dividend" ever assigned the values within "my_vector"? To be more specific; Where exactly in this process is this happening: "dividend = my_vector[x]"? I assume that must happen in some way shape or form somewhere in order for dividend to not remain null or undefined or whatever a variable that hasn't been made equal something is called.
I know if it was a function you would type: and that is how dividend would be assigned.

mrprofile
Автор

My musing on this is why didn't they just require the compiler authors to scan the lambda for variable uses and just infer the captures in lieu of any shadows. It's not as though they aren't going to parse the entire thing at compile time anyway. Only reason I can think of is that they didn't want to introduce a keyword. As in, how would they designate that it is a lambda without a keyword. Well, brackets. And why merely have empty brackets when you can make them do something. Personally, I think JavaScript is slightly better in this respect, but because of how loose it is with variable declarations it kind of ruins the better syntax. At least, with regards to C++, we don't have some disgusting functional language syntax. That would be truly abhorrent. Any language that would use a syntax such as: let plus1 = |x| x + 1; // is just garbage.

anon_y_mousse