C++ 11 Lambda Functions

preview_player
Показать описание
In this video we'll look at a new style for implementing anonymous functions in C++ 11 and above. They're called Lambda functions, and they allow us to define little functions right where we need them, instead of adding a prototype, and a function in some header.

The Lambda syntax does not offer anything we could not otherwise program, but they are convenient, and they can help to reduce the overall amount of code in our projects.

Become a patron and support What's a Creel programming vids on Patreon:

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

Best video for Lambda functions. I wasted a lot of time with other articles and videos and finally came here. Your explanation is awsome.

naganikhilbijjala
Автор

Thank you sir for posting the only lambda tutorial that makes any sense whatsoever, finally

benvaldivieso
Автор

This is absolutely the clearest video for explaining the lambda function in C11! 😃

zijiezhou
Автор

OH! This is an amazing video ever made on c++11 Lambdas...All my doubts about Lambdas got resolved today. Thank You great man.

krantimadineni
Автор

"And You are all bunch of Legends" touched my Heart❤️
Thank You Sir
I have been trying to learn lambda functions from websites and didn't understand a single word
A teacher is really Important Thanks a Lot again ❤️

Muhammad_Waleed
Автор

Amazing !

Certainly the best introduction to C++ lambda functions, both in breadth of coverage and good humor.

HiltonFernandes
Автор

A great tutorial that builds gradually from the very basic to the more complex syntax, explaining all the aspects of lambda functions so clearly. Thank you!

shvideo
Автор

Best Lamda introduction I've found, very helpful. Thank you!

Kenforbes
Автор

Man, you just made my day... I've been trying to pass a complicated line of code into a std::thread for days now, and the Lambda function solved it.

frozenfirebat
Автор

best lamda function explanation on the tube yet

logomoniclearning
Автор

"i and g are read-only because we're passing by value to the body of our lambda."

That's not _quite_ right. A lambda with a capture list is actually a functor whose `operator()` is const. When a variable is captured by value, it becomes a data member of the functor. Because const functions can't modify their data members (by default), then you can't modify variables captured by value. A reasonable person might then think that capturing by reference would capture by const reference. But no. Someone decided that capturing by reference would be done non-const. There is a way to allow const member functions to modify their data members: by marking them _mutable_. You can also do this with lambdas.

int i = 3;
auto f = [i]() mutable { i = 4; return i; };
std::cout << f() << std::endl;

This becomes quite useful when using the non-mutating standard algorithms on containers of third-party classes that aren't const-correct. This can be a real pain in the jacksie!

As an aside, lambdas with an empty capture list can "decay" into classic function pointers because they aren't functors as they don't need any state.

Thanks for another great video! Have you thought about making a video on combining C++ and assembly? I would definitely watch it!

communistgoatboy
Автор

best lambda explanation on the internet, thanks

poganka
Автор

In your "simplest lambda", I think you can omit the parenthesis and make it even simpler:

[]{};

(Works in Visual Studio at least, but I think this is standard).

djpeterson
Автор

Understanding lamba is made very easy here. Thumps up for posting the video.

mohanrajanna
Автор

amazing toturial finally somebody explains clear and with good examples!! thank you for the order man!

IceScream
Автор

Great video. You pushed me over the threshold. I'm finally understand lambdas. Thank you!

AegirAexx
Автор

""The return of the Lambda", haha sounds like a horror film." HAHAHA, love your tutorials!

danielgospodinow
Автор

Clearest video ive watched on this thank you

shrimpfights
Автор

Outstanding simplicity and informative. Top notch!

alski
Автор

You're the good legend here Creel :D

Awesome high-quality content, generally detailed low-level explanations, and cool Aussie accent. Gotta love this channel!

Wish I could be a supportive patron, but can't from here. :/ Salutes from Syria anyways. :P

(The hype of "Return of Lambda" is unprecedented). xD

majoro