C++ 11 Lambda Functions

  Рет қаралды 73,344

Creel

Creel

Күн бұрын

Пікірлер
@naganikhilbijjala1000
@naganikhilbijjala1000 6 жыл бұрын
Best video for Lambda functions. I wasted a lot of time with other articles and videos and finally came here. Your explanation is awsome.
@alltheway99
@alltheway99 4 жыл бұрын
Agree, a good one, Another one I liked kzbin.info/www/bejne/o4jKnnV4r5WsbsU
@Manishbhaiya_rock
@Manishbhaiya_rock 4 жыл бұрын
Agree
@zijiezhou4179
@zijiezhou4179 2 жыл бұрын
This is absolutely the clearest video for explaining the lambda function in C11! 😃
@benvaldivieso3326
@benvaldivieso3326 Жыл бұрын
Thank you sir for posting the only lambda tutorial that makes any sense whatsoever, finally
@krantimadineni585
@krantimadineni585 7 жыл бұрын
OH! This is an amazing video ever made on c++11 Lambdas...All my doubts about Lambdas got resolved today. Thank You great man.
@Muhammad_Waleed
@Muhammad_Waleed Жыл бұрын
"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 ❤️
@HiltonFernandes
@HiltonFernandes 4 жыл бұрын
Amazing ! Certainly the best introduction to C++ lambda functions, both in breadth of coverage and good humor.
@shvideo1
@shvideo1 6 жыл бұрын
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!
@logomoniclearning6680
@logomoniclearning6680 7 жыл бұрын
best lamda function explanation on the tube yet
@Kenforbes3
@Kenforbes3 3 жыл бұрын
Best Lamda introduction I've found, very helpful. Thank you!
@frozenfirebat
@frozenfirebat 7 жыл бұрын
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.
@mohanrajanna9026
@mohanrajanna9026 4 жыл бұрын
Understanding lamba is made very easy here. Thumps up for posting the video.
@danielgospodinow
@danielgospodinow 8 жыл бұрын
""The return of the Lambda", haha sounds like a horror film." HAHAHA, love your tutorials!
@joeytribbiani1787
@joeytribbiani1787 7 жыл бұрын
The Silence Of The Lambdas :D
@waqar_asgar__r7294
@waqar_asgar__r7294 6 жыл бұрын
i was gonna type this
@poganka45
@poganka45 6 жыл бұрын
best lambda explanation on the internet, thanks
@communistgoatboy
@communistgoatboy 9 жыл бұрын
"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
@WhatsACreel
@WhatsACreel 9 жыл бұрын
+communistgoatboy Brilliant! Thanks for sharing.
@AegirAexx
@AegirAexx 7 жыл бұрын
Great video. You pushed me over the threshold. I'm finally understand lambdas. Thank you!
@IceScream729
@IceScream729 5 жыл бұрын
amazing toturial finally somebody explains clear and with good examples!! thank you for the order man!
@vintage8818
@vintage8818 7 жыл бұрын
extremely informative tutorial video and extremely awesome way to deliver the lecture. Lambda functions suddenly seem so tameable to me now. Thanks. 😊
@WhatsACreel
@WhatsACreel 7 жыл бұрын
Welcome, thanks for watching!
@alski259
@alski259 2 жыл бұрын
Outstanding simplicity and informative. Top notch!
@djpeterson7479
@djpeterson7479 9 жыл бұрын
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).
@s-c-iulian
@s-c-iulian 7 жыл бұрын
4:24 "The Return of The Lambda" , I just explode in laughter, the most epic things it can be heard on your channel ...
@shrimpfights1714
@shrimpfights1714 3 жыл бұрын
Clearest video ive watched on this thank you
@majoro7251
@majoro7251 9 жыл бұрын
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
@WhatsACreel
@WhatsACreel 9 жыл бұрын
+Major O Thanks, you're a hero!
@amanuel2135
@amanuel2135 8 жыл бұрын
+What's a Creel? No one who uses using namespace std; is a legend... Not only that but he does using namespace std, and then still just uses std::vector ...??
@creelsmusic5814
@creelsmusic5814 8 жыл бұрын
+Amanuel Bogale Classy! Can I get you some salsa to have with that chip on your shoulder? Seriously though, thanks for watching, and have a good one!
@amanuel2135
@amanuel2135 8 жыл бұрын
What's a Creel? i would actually love that. As One Of my Favorite(Eat it almost all the time) is Salsa!
@bouzie8000
@bouzie8000 7 жыл бұрын
This is a great video. You broke it down perfectly. Could you please do a series on systems programming
@jjpark98
@jjpark98 6 жыл бұрын
Thanks, this really helped me understand. Wasn't as hard as I initially thought
@mandrohz5598
@mandrohz5598 8 жыл бұрын
your tutorial is so good. clear fast and direct. really helpfull thanks!
@RaviKumar-zp8pm
@RaviKumar-zp8pm 7 жыл бұрын
love the way of teaching and some interesting dialogue in the middle made me laugh hahaha!!
@gprozac
@gprozac 3 жыл бұрын
Thanks man,cool explanation about lambdas.
@emirmujezinovic5550
@emirmujezinovic5550 6 жыл бұрын
Very nice video, you made it fun to learn it, thanks for it😁
@修无
@修无 6 жыл бұрын
It's very useful and easy to understand.
@fipabrate
@fipabrate 7 жыл бұрын
In last example ( 18:22 ) what is the difference between (function f ) and (function &f ). Basically, when should i use '&f' and when just 'f'
@asiseverything3404
@asiseverything3404 3 жыл бұрын
&f and f can be used interchangeably. typing &f is a good practice though.
@quentinz6291
@quentinz6291 3 жыл бұрын
Good tutorial for cpp lambda, thank you
@KunalMukherjee3701
@KunalMukherjee3701 6 жыл бұрын
Very nicely put, kudos
@taitai5108
@taitai5108 2 жыл бұрын
very detail explanation. thank you
@carlinconnell7715
@carlinconnell7715 9 жыл бұрын
Yeah, thanks man. Very good videos.
@xpfe5zrm
@xpfe5zrm 6 жыл бұрын
Perfect, easy explanation. Thank you.
@IllIlIIllIlIl
@IllIlIIllIlIl 7 жыл бұрын
12:10 This made me laugh harder than I care to admit..
@ChillerDragon
@ChillerDragon 7 жыл бұрын
xxxxxxxxxxxD true
@stevejones9044
@stevejones9044 6 жыл бұрын
I know right! He did that "asdfasfdasdfasfd" thing a few times which cracked me up every time.
@cloveramv
@cloveramv 6 жыл бұрын
And this Guys is what is *Ultra instincts !!* . . . 15:17 *Ultra Instincts !!*
@adamodimattia
@adamodimattia 4 жыл бұрын
yeah, it got me too, but when I rewatched it :) first time I was like: well that was a general example... :D
@Maduin1337
@Maduin1337 3 жыл бұрын
Stroke Oriented Programming I laughed way too hard aswell, it's like getting your mate showing you some programming tricks. Laid back dude!
@davidutv
@davidutv 9 жыл бұрын
Hey mate, nicely done. I really enjoyed how you typed kjhgycikjhgfckiuy for explaining the definition of other code somewhere else :) One nit I did find, when you said end() provides a pointer to the (last) element; this isn't quite true :) I'm sure you know that end() returns one past the last element in the vector ;-) Still, great video; enjoyed it immensely! Happy New Year, BTW!
@PRATHAMPAI
@PRATHAMPAI 6 жыл бұрын
Amazing video, thank you so much.
@mohshafi3032
@mohshafi3032 6 жыл бұрын
Thank you for your time, and a well explained lecture. Could you please explain in more detail why the ampersand(&) in front of the variable point (point&) in the sort algorithm by the lambda fragment of the code like this [ ](const point& a, const point& b). And also the purpose of the const.
@gnarfgnarf4004
@gnarfgnarf4004 4 жыл бұрын
'&' pass by reference, instead of by value. Reduces the size of the stack if it's an object. 'const': the function can't change the parameter.
@bestraub98
@bestraub98 9 жыл бұрын
If you started your program without debugger (ctrl + F5), it would take a lot less time to start up. Also you could omit the breakpoint at the end, because the console stays open after that until you press enter. (at least in visual studio 2015)
@WhatsACreel
@WhatsACreel 9 жыл бұрын
+bestraub98 Cheers! Thanks for the info.
@arbadon
@arbadon 9 жыл бұрын
Excellent explanation, thank you!
@jessprogany4345
@jessprogany4345 3 жыл бұрын
loving your tutorials hope to see more of C++ I have a question though does lamda function capture only the variables declared over lamda function definition or does it capture all of the variables of the scope where lamda function is defined?
@ME0WMERE
@ME0WMERE 2 жыл бұрын
Probably only over, as otherwise you would be referring to a variable that doesn't exist
@smeagolfishy
@smeagolfishy 8 жыл бұрын
Thank you! You're a great teacher
@muhammadhaseeb4096
@muhammadhaseeb4096 6 жыл бұрын
Thank you for this video.
@privateerburrows
@privateerburrows 3 жыл бұрын
Can you write lambdas that evaluate at compile time or static time, such as for initializing constants and static globals? There's a wonderful thing in the Eiffel language called "once function", which is any function pre-attributed with the keyword 'once', that only compute their output the first time they are called, but on subsequent calls return the same value they originally computed. They are a great replacement for global constants. In C-ish notation, once size_t bus_cycles_per_cache_line(){ cache_line_sz() / bus_width(); } //in some other file... once size_t cache_line_sz(){ cpuid(...); } once size_t bus_width(){ whatever(...); } It forces these evaluations to happen in the right order, as opposed to C/C++ which clearly states that the order of evaluation of static initializations is undefined. So these are lazy static initializations, at run-time for the most part, really; but they may be called as early as at compile time if a result is needed at compile time. I've often wondered if there's a way to replicate once functions in C++.
@PhaseFabrication
@PhaseFabrication 4 жыл бұрын
dude i love your videos
@sikendongol4208
@sikendongol4208 5 жыл бұрын
Return of the Lambda
@defaultdefault812
@defaultdefault812 3 жыл бұрын
How does foreach 'know' what to pass to the lambda, in this case int x. Expressed alternatively, how is int x being assigned?
@Wanderlust073
@Wanderlust073 3 жыл бұрын
Excellent video
@ExD3aD
@ExD3aD 7 жыл бұрын
shouldn't the int [&](int x) be [&](int& arr) 12:52 ?
@duydong78
@duydong78 7 жыл бұрын
Great explanation! Thanks!
@Asimov16
@Asimov16 7 жыл бұрын
Can you tell me what use is Lambda's when you could easily just make a function or method instead. I understand how they are used now thanks, just can't understand their use if you can use a function
@WhatsACreel
@WhatsACreel 7 жыл бұрын
They're just a different way to do things. They don't offer anything new, but they're pretty convinient soemtimes. I think the best examples of how powerful they are is when you look at processing lists, like filtering of perfomring some operation on the values. I hoep that makes some sense...?
@shashi3146
@shashi3146 3 жыл бұрын
here in this lambda function we are passing [] (int x) what is x and how internally it is working.please elaborate it as i am new to this.
@JL-uz1fu
@JL-uz1fu 8 жыл бұрын
When I tried running the first program, it just says: q.cpp:10:7: error: ‘sayHelloWorld’ does not name a type
@malharjajoo7393
@malharjajoo7393 7 жыл бұрын
what is the difference between capure list ( "[=]" ) and passing by value in paramter list. ?
@nikarm22
@nikarm22 7 жыл бұрын
Capture list takes values when lambda is defined, but parameter is given when you are calling the function. So when you call the same lambda, you can pass different params, but capture list is always the same.
@rafaelocariz1384
@rafaelocariz1384 6 жыл бұрын
Hello! I'm facing some problems with lambda, I need to declare a function who execute something different depending on the input, on the other programs of the project this function is being called like this: int_op["add"](3, 5), but Lamba isn't supposed to be named and they are calling that way, how can I implement this int_op function?? please, help
@adamodimattia
@adamodimattia 4 жыл бұрын
Good tutorial!
@ADonT100
@ADonT100 8 жыл бұрын
can you pls explain the Operator Overloading ,Element & globale Funktion
@himansumaurya2883
@himansumaurya2883 3 жыл бұрын
Can u make video on recursive lamda using y_combinator
@gnarfgnarf4004
@gnarfgnarf4004 4 жыл бұрын
Thank you for a clear and lucid introduction to lambdas. However, I still don't see the benefit of lambdas. The additional complexity is not offset by the convenience. In fact, defining the function in-line complicates the flow of logic. Defining the lambda as a separate function, the old-fashion way, would improve code legibility.
@malharjajoo7393
@malharjajoo7393 7 жыл бұрын
The syntax in your first few slides does not have the "=" sign after the name. Are they incorrect ?
@narayananms620
@narayananms620 8 жыл бұрын
brillaint guy/video, loved it
@jony7779
@jony7779 7 жыл бұрын
Thank you for this.
@manfredpseudowengorz
@manfredpseudowengorz 3 жыл бұрын
2:45 - Uuuuuu... What does this lambda do? - It compiles.
@filipjacobsen2468
@filipjacobsen2468 7 жыл бұрын
Thank you Obi One Kenobi :D
@pengzuo7551
@pengzuo7551 7 жыл бұрын
impressed , by the way, which accent is this speaker.
@WhatsACreel
@WhatsACreel 7 жыл бұрын
Thanks for watching. I'm Australian :)
@novictim
@novictim 4 жыл бұрын
Very informative !!!
@TheGnarTube
@TheGnarTube 6 жыл бұрын
iterator end() points to one element past the end, not to the last element
@BryonLape
@BryonLape 8 жыл бұрын
Why is it that C++ seems to break encapsulation at every opportunity?
@t-h787
@t-h787 6 жыл бұрын
epic video mate, very informative + i lol'd several times :P
@commentor5479
@commentor5479 4 жыл бұрын
So you're that youtuber the other channel was asking about!
@WhatsACreel
@WhatsACreel 4 жыл бұрын
Not sure mate, what channel? Thanks for watching :)
@commentor5479
@commentor5479 4 жыл бұрын
@@WhatsACreel The channel named "What's a Creel?"
@WhatsACreel
@WhatsACreel 4 жыл бұрын
@@commentor5479 Hahaha, that's gold! I fell for that hook line and sinker :)
@commentor5479
@commentor5479 4 жыл бұрын
Wait. You're the same channel.
@WhatsACreel
@WhatsACreel 4 жыл бұрын
@@commentor5479 Yep, just changed the name :)
@SearchingPeaceInside
@SearchingPeaceInside 7 жыл бұрын
Good Tutorial.
@Coffeemancer
@Coffeemancer 3 жыл бұрын
can you tell C# ?
@aioaneiadrian9232
@aioaneiadrian9232 8 жыл бұрын
Nice job :)
@WatchesTrainsAndRockets
@WatchesTrainsAndRockets 3 жыл бұрын
The expression "using namespace std" is an abomination created in the textbooks and should be avoided. The problem is, for those who may not know, the using expression makes ALL of the symbols within the referenced namespace local to the context enclosing the using clause. If you happen to do this for multiple namespaces, you can get some weird collisions that are hard to diagnose. This possibility is eliminated by just not employing the using clause and explicitly specifying the namespace containing the symbol being referenced. In the code here that would mean writing "std::cout
@bluehornet6752
@bluehornet6752 6 жыл бұрын
I think this shit is what Bjarne Stroustrup meant when he said "With C++ you can blow your whole leg off."
@nikolaossmyrnioudis397
@nikolaossmyrnioudis397 6 жыл бұрын
Eric Idle, is that you ?
@WhatsACreel
@WhatsACreel 6 жыл бұрын
Hahaha, being likened to a Python is the greatest honor of all!!
@cloveramv
@cloveramv 6 жыл бұрын
15:17 *Ultra Instincts !!*
@schermann1995
@schermann1995 7 жыл бұрын
very helpful thx :)
@tuckerhartland1001
@tuckerhartland1001 2 жыл бұрын
I don't really understand why you say that the lambda function has no name. In the first example isn't "sayHelloWorld" acting like a name to the lambda?
@mahdies9620
@mahdies9620 3 жыл бұрын
you are the best
@yousufazad6914
@yousufazad6914 8 жыл бұрын
make another video please! :D
@bandamkaromi
@bandamkaromi 9 жыл бұрын
thanks..
@Sarcasticpigeon
@Sarcasticpigeon 6 жыл бұрын
Great video, but I cannot get over the lack of indentation. (0-e)
@WhatsACreel
@WhatsACreel 6 жыл бұрын
Hahaha, the indentation in this vid is a mess! I normally use Whitesmith. It's not popular, but it's super easy to read. But I have to save space on the slides, so I used like K&R. Then I mixed the two together because I'm a moron :S Sorry if it was confusing, hope the vid still made sense and thanks for watching!
@Sarcasticpigeon
@Sarcasticpigeon 6 жыл бұрын
What's a Creel? It was definitely helpful, I loved how quickly you move through it. :)
@Rokannon
@Rokannon 9 жыл бұрын
This video is really good. Thank you very much. The only thing that I would like to have to know after this video is whether anonymous functions have any overhead comparing to classic approach. Because C++ is a great language performance-wise and using these fancy tricks by paying some performance cost would be just gay. Also I have subscribed to your channel. Many interesting videos on C++ I see. Because I am studying C++ at the moment and when you study new programming language it is really important to see someone having fun with it which you totally do, sir. But more importantly I am fading away from such politicaly incorrect languages as Java and ActionScript. If you heard some stories about garbage collection and virtual machine performance issues then you know what I mean.
@oddarnebeck
@oddarnebeck 7 жыл бұрын
I guess there's a reason for the guys saying "stood" instead of "ess tee dee" when talking about "std::". Good video though, thanks!
@azzam7239
@azzam7239 4 жыл бұрын
I think because std usually stands for sexually transmitted disease
@RupertBruce
@RupertBruce Жыл бұрын
A new tool for obfuscation! It looks to be a way of doing functional programming in C++ but it has a lot of potential for abuse!
@spread2081
@spread2081 4 жыл бұрын
wait this is cool
@abhikghosh5220
@abhikghosh5220 2 жыл бұрын
The best
@hatedbytheworld1373
@hatedbytheworld1373 5 жыл бұрын
Easy as Pi😄
@sikendongol4208
@sikendongol4208 5 жыл бұрын
in place
@srahimi5007
@srahimi5007 8 жыл бұрын
Lambda if not used properly produces more mess than good. I acknowledege its existance but wont use it . It is in contrarty to what the concept of OO seems to be. why would you wanna have a function within main? it is turning this language into something worse than assmembler.... however tutorial was excellent
@DuhBroadcaster
@DuhBroadcaster 8 жыл бұрын
Not every problem needs to be OO-style. In some cases, it's just a waste of time and work to try converting it into that style. Dismissing a tool can only hurt you as a programmer.
@akash-iichaudhari5123
@akash-iichaudhari5123 4 жыл бұрын
Day saver
@abcdeereijgfhd3215
@abcdeereijgfhd3215 3 жыл бұрын
I don't like the naming of std since it also means "Sexually Transmitted Desease"
@kumu2024
@kumu2024 4 жыл бұрын
It is just about making harder to read.. I don't think there is any performance benefit of this feature. Rewriting you old code and making it harder to read. That is all about .. in my opinion. Many new CPP technique is like so.. It is not really a new thing than making it harder to read.
@clifforddicarlo9178
@clifforddicarlo9178 Жыл бұрын
I REALLY don't see or appreciate the value of lambda functions. All it does is make your code less readable. Can C++ "live"without Lambda Functions?
@pasanyrebiata5430
@pasanyrebiata5430 6 жыл бұрын
Do you like to drink? I think do you be nice alcoholism companion
@xDR1TeK
@xDR1TeK 6 жыл бұрын
I haven't coded in a while. I saw it in a coding conference and raised flags on me. I think it is an abomination. It infringes on many coding conventions. Conventions that were specifically agreed upon to prevent loosely written code that ends up churning useless asm lines. Mind you that this is only churning at compile time, but still, convention says changing one line or adding few years to this code, compile is no longer guaranteed. I think behavior wouldn't be guaranteed at all. What strikes me the most, people who are in position to make changes to compilers forget that there are people in this world that are not just software oriented but also hardware oriented. This is why I think people making changes to the compiler are not fit to make changes at all. I know being old fashioned has no place in the future but just saying you know. I'm old. I don't like this new change because lambdas are imposing suggestions that infringe on conventions.
@WhatsACreel
@WhatsACreel 6 жыл бұрын
You don't like lambdas? Yes, they are a little strange for C++. The syntax is probably my least favourite thing about them. But, they're really fun and fairly useful time savers sometimes, so it's ok to get used to them. Thanks for watching anywho, have a good one!
@oraclematon9277
@oraclematon9277 3 жыл бұрын
great tutorial
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 839 М.
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
C++ - lambda expressions
14:51
Bradley Needham
Рет қаралды 46 М.
Top 10 Craziest Assembly Language Instructions
15:19
Creel
Рет қаралды 462 М.
C++ Function Templates
36:02
Creel
Рет қаралды 13 М.
Lambda expressions in modern C++ (in depth step by step tutorial)
18:35
Lambda Expressions in C++ 11/14
44:49
Programming
Рет қаралды 24 М.
Master Pointers in C:  10X Your C Coding!
14:12
Dave's Garage
Рет қаралды 334 М.
lvalues and rvalues in C++
14:13
The Cherno
Рет қаралды 327 М.
Vim Tips I Wish I Knew Earlier
23:00
Sebastian Daschner
Рет қаралды 82 М.
C++ Weekly - Ep 332 - C++ Lambda vs std::function vs Function Pointer
16:30
C++ Weekly With Jason Turner
Рет қаралды 34 М.
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН