the way to become a C++ expert: read and entirely internalize the standard. I haven't and that's why, after decades - DECADES! - of C++ use and work I'm still watching these videos!
A couple of small notes: * don't start manually ordering all of your lambda captures. This is not behavior that is specified in the standard. I just wanted you to be aware of it. * Some of the C++ standards / features got off, my mistake. Example: Explicit template parameters for lambdas are from C++20. I'll continue to update this comment for this very dense episode as things are found.
Ever since I started developing in C++ with my first job in 1997, I had the feeling that the more years of experience in C++ I had, the less confident I became, and the more there was that I didn't know. Now, I have an extensive list which I can go through and improve on (or even get to know, for that matter) all the topics I don't feel confident enough in. Thanks a lot, Jason! That list is very helpful! And the video's a lot of fun to watch😁
I am really glad that you wrote this comment, because I made the same experience. And thanks Jason really helpful, like your videos. 20 minutes are perfect to watch (not to short not to long)
Just be aware that I would put this in the category of hyper optimization if you start going around manually ordering captures. This is not, nor should be, a normal thing to do. And it's also not specified by the standard.
More than practice, something I have seen to helps a lot to improve at programming with a certain language/framework/technology/etc. is to reads others peoples code.
Hallo Jason, Great job bringing this to the public. I am pretty new to c++ and wouod appreciate if you make show us which topics to know for beginner and intermediate .
@3:37 Is the absence of an inherent 'this' pointer for lambdas an intentional design to avoid such ambiguities, or is there another rationale behind it? I'm speculating that this design choice might be due to potential ambiguities, especially in scenarios where a lambda might capture the 'this' pointer of an enclosing class. If lambdas inherently had a directly accessible this pointer (like regular objects), and they also captured an enclosing this, it could lead to confusion. Am I right?
Sure, but he didn't say that the covered topics are *all* the things that the "expert level" is comprised of, just that they *are* at the "expert level"
@@cppweekly What did you think of Herb Stutter's presentation on his cpp2 proposal? It seems like he has more actual pragmatic headway on his ideas than does the Google Carbon project (and seems like, to me, Herb is taking a superior approach in respect to migration from and compatibility with the C++ parent language) Would be great to hear your observations in a video
7:00 - I think 'efficiency when chaining functions' belongs somewhere near here and not earlier where you put it. When the parameters were int and int &, there was, very technically, a copy issue, I suppose. But no compiler would've cared. But, as soon as you made it a template with a T first parameter, there was definitely an issue.
I didn't understand 'efficiency when chaining functions' , and googling doesn't seem to help (maybe I'm not searching the right terms). Where could I learn about this from?
That's a C++23 feature know as multiple keystroke elision. The compiler figures out that you are writing the same thing twice and auto populates code for you. Jokes aside in clion Ctrl+Shift+Click let's you set multiple cursors for typing the same thing. It's available in VSCode too.
Hi, really want to know what is the template overload(Ts...) -> overload means and does. It does no sense to me and I never see anything similar in my life ever, don't even know how to Google it..
Do you need to duplicate the static method inside the lambda, CPP insights seems to delegate to the member function implementation from the static method via a temporary (which should be fine since these are captureless lambdas) ? Also presumably with inlining the overhead of delegating should be zero (at least at higher optimization levels) ?
CppInsights is not technically correct here, it's impossible to get the same guarantees as the standard requires using delegating code like they are. In general it's actually impossible to directly model what the compiler does for Lambdas using user defined code.
As for "your favorite C++ feature"---did I miss it, or were designated initializers left out? Not that it's my _absolute_ favorite, but it's super useful for improving code health.
Template meta programing, this means in simple terms code that take one type and return other type that have specific relation to first one, e.g. "preferred container for type X", and you by default return `std::vector` but for other it would be `std::list` or better `std::deque`. And this is only tip of iceberg.
I have a weird relationship. I have used (and do use) it extensively when I need to. But in my mind it is kind of a technique to use when there isn't a better option. I find fewer and fewer uses for it as constexpr becomes more powerful. But you are correct, I didn't really mention that in the episode.
Once you know how a lambda works you expect that `this` should refer to the lambda object itself, but it does not. It can only refer to a captured `this` pointer. There is no way to model this with equivalent code. It's "magic"
@@cppweekly There is still a "this" pointer except that it can't be referred to using this. IOW, the first argument to the lambda (if it has one) is passed into %esi vs. %edi.
Great checklist and presentation. Covers almost everything In the language except modules and coroutines. Curiously, there is no array manipulation or memory allocation, and pointers are (happily) thin on the ground. Others have mentioned other lacunae but, after them, we’re into esotericism like atomics and laundry.
Man! That felt fantastic, and it was quite motivational. :) Title can be, 20 mins of Self-confidence in C++ Well, I have a little thought too, about std::tuple{}; 10:17 - Why std::apply isn't used here? I believe, it would simplify the code, + would make it much, much readable.
@@cppweekly Sorry, I was trying to make a terrible pun about "exceptions, the C++ feature". Of course, I could easily have missed that you _did_ talk about them, and then the joke's on me!
Has anyone ever said that? My approach has always been: if you understand C++ then you understand computers (knowing machine architecture, instruction set and assembler are prerequisites IMHO too). C++ is life-long learning, which is great for educators like, er, Jason.
@@treyquattro I think that before learning C++, it could be taught much better if firstly general concepts of how compilation actually is done in real world, and how CPUs work are taught. So many things started to get their understandable place after learning a bit about these concepts...
Not sure if useful as an idea for a video or even if it happens to other people. I can understand modern c+- but i cant write because older stuff seems easier to me. Ps. I am c++ dumb but i people still pay me to develop software on other languages, so i suppose i am not the most terrible programmer
Some bonus features:
* exceptions, catch ellipse
* structured binding
* forward declaration
* namespaces
* rule of 5, default and nontrivial/virtual destructors
* memory, pointers and smart pointers
* iterators and writing your own iterator
* multithreading
* numeric
* explicit/implicit conversions
* casting, slicing
* variant & visitor
* abstract class (pure virtual), delete, final
* consteval
* packages & libraries, cmake
* signed/unsigned arithmetic, bitwise operations, bitset
empty base optimization
just a little bonus >w
the way to become a C++ expert: read and entirely internalize the standard. I haven't and that's why, after decades - DECADES! - of C++ use and work I'm still watching these videos!
Haha yeah
It must be frustrating.
How would you go about doing that?
A couple of small notes:
* don't start manually ordering all of your lambda captures. This is not behavior that is specified in the standard. I just wanted you to be aware of it.
* Some of the C++ standards / features got off, my mistake. Example: Explicit template parameters for lambdas are from C++20.
I'll continue to update this comment for this very dense episode as things are found.
Ever since I started developing in C++ with my first job in 1997, I had the feeling that the more years of experience in C++ I had, the less confident I became, and the more there was that I didn't know. Now, I have an extensive list which I can go through and improve on (or even get to know, for that matter) all the topics I don't feel confident enough in.
Thanks a lot, Jason! That list is very helpful! And the video's a lot of fun to watch😁
I am really glad that you wrote this comment, because I made the same experience. And thanks Jason really helpful, like your videos. 20 minutes are perfect to watch (not to short not to long)
I am amazed at myself that at 13:00 I actually thought about ordering, size of lambdas JUST before you mentioned it. Feeling proud.
Just be aware that I would put this in the category of hyper optimization if you start going around manually ordering captures. This is not, nor should be, a normal thing to do. And it's also not specified by the standard.
More than practice, something I have seen to helps a lot to improve at programming with a certain language/framework/technology/etc. is to reads others peoples code.
Hallo Jason,
Great job bringing this to the public. I am pretty new to c++ and wouod appreciate if you make show us which topics to know for beginner and intermediate .
I've tried to put together an ordered playlist for "learning" topics ua-cam.com/play/PLs3KjaCtOwSY34fFKyhOFovFlB7LikDwe.html
@3:37 Is the absence of an inherent 'this' pointer for lambdas an intentional design to avoid such ambiguities, or is there another rationale behind it? I'm speculating that this design choice might be due to potential ambiguities, especially in scenarios where a lambda might capture the 'this' pointer of an enclosing class. If lambdas inherently had a directly accessible this pointer (like regular objects), and they also captured an enclosing this, it could lead to confusion. Am I right?
Very intentional - `this` always refers to the containing object that the lambda was created in.
move semantic and forwarding/universal ref
You left out multithreading and maybe the memory model (?)
Sure, but he didn't say that the covered topics are *all* the things that the "expert level" is comprised of, just that they *are* at the "expert level"
@@johanngerell sure. He also asked to comment things he might had left out. =D
@@PedroOliveira-sl6nw fair enough :)
Well, after using C++ for a last 6 years, its still a really long path for me to be an expert... :D I fell like i know nothing now..:X
I guess that will never change....feel you :D
90 shots of C++ Espresso
a booklet could be fashioned around this presentation and it would make a nice companion quick reference - kudos for this nifty angle of attack
You might check out this one: leanpub.com/cpplambda I have not read it, but it should have a fair bit of overlap.
@@cppweekly What did you think of Herb Stutter's presentation on his cpp2 proposal?
It seems like he has more actual pragmatic headway on his ideas than does the Google Carbon project (and seems like, to me, Herb is taking a superior approach in respect to migration from and compatibility with the C++ parent language)
Would be great to hear your observations in a video
7:00 - I think 'efficiency when chaining functions' belongs somewhere near here and not earlier where you put it. When the parameters were int and int &, there was, very technically, a copy issue, I suppose. But no compiler would've cared.
But, as soon as you made it a template with a T first parameter, there was definitely an issue.
I didn't understand 'efficiency when chaining functions' , and googling doesn't seem to help (maybe I'm not searching the right terms). Where could I learn about this from?
@@dascool3st did you find some info about it yet?
Friend functions?
How are you typing both in the void lambda() and the struct Lambda() at the same time? what sorcery is this @ 4:21?
That's a C++23 feature know as multiple keystroke elision. The compiler figures out that you are writing the same thing twice and auto populates code for you.
Jokes aside in clion Ctrl+Shift+Click let's you set multiple cursors for typing the same thing. It's available in VSCode too.
Hi, really want to know what is the
template overload(Ts...) -> overload
means and does. It does no sense to me and I never see anything similar in my life ever, don't even know how to Google it..
You want to look up "C++ deduction guide" which guides from ctor to template params.
Do you need to duplicate the static method inside the lambda, CPP insights seems to delegate to the member function implementation from the static method via a temporary (which should be fine since these are captureless lambdas) ? Also presumably with inlining the overhead of delegating should be zero (at least at higher optimization levels) ?
CppInsights is not technically correct here, it's impossible to get the same guarantees as the standard requires using delegating code like they are. In general it's actually impossible to directly model what the compiler does for Lambdas using user defined code.
@@cppweekly thanks. What are the guarantees that might be violated with delegation?
Last time I used C++ seriously was almost 10 years ago. How to grasp all those new concepts? Any advice of a good reference?
I tend to recommend "A Tour of C++" which is linked in the video description.
exceptions should be easy to add to the list as well
As for "your favorite C++ feature"---did I miss it, or were designated initializers left out? Not that it's my _absolute_ favorite, but it's super useful for improving code health.
I did miss designated initializers, you're right
My favorite feature you didn’t cover, which can apply to lambdas in various ways: concepts and constraints.
I touch on it at 8:42 briefly.
@@cppweekly Oops, you did, I missed that.
Template meta programing, this means in simple terms code that take one type and return other type that have specific relation to first one, e.g. "preferred container for type X", and you by default return `std::vector` but for other it would be `std::list` or better `std::deque`.
And this is only tip of iceberg.
And?
I have a weird relationship. I have used (and do use) it extensively when I need to. But in my mind it is kind of a technique to use when there isn't a better option.
I find fewer and fewer uses for it as constexpr becomes more powerful.
But you are correct, I didn't really mention that in the episode.
@@cppweekly yup, most fun experiment I make was creating Stack Turing Machine purely using template metaprograming :D
How are you typing so fast ? What keyboard are you using ?
It's sped up.
Could you explain 3:32?
Once you know how a lambda works you expect that `this` should refer to the lambda object itself, but it does not. It can only refer to a captured `this` pointer. There is no way to model this with equivalent code. It's "magic"
@@cppweekly There is still a "this" pointer except that it can't be referred to using this. IOW, the first argument to the lambda (if it has one) is passed into %esi vs. %edi.
explicit lambda templates were added in C++20, not in C++17
I Am new to C++ this channel is amazing but were do i start?
somewhere around episode 5 I think :D
I did not find the video topics list nor in the description, nor in the comment section:
* lambdas
* struct
* constexpr
* operator overloading
* call operator
* const member functions
* braced initialization
* `auto` return type deduction
* "compiler magic"
* function parameters
* pass-by-value
* attributes on parameters
* pass-by-reference
* pass-by-value vs pass-by-reference
* pre-increment vs post-increment
* trailing return types
* class vs struct
* private vs public
* implicit conversions
* function pointers
* static member functions
* using aliases
* efficiency when chaining functions
* templates
* template argument type deduction
* alias templates
* template instantiations
* `noexcept`
* `noexcept` in the type system
* variadic templates
* variadic lambdas
* fold expressions
* function attributes
* concepts
* non-type template parameters
* integer sequences
* template parameter pattern matching
* explicit lambda templates
* tuples
* unpacking of tuples
* variadic `sizeof...()` operator
* direct-initialization of members
* `mutable` keyword
* non-`const` member functions
* reference members
* member copies
* object layout
* member padding
* order of construction / destruction
* generalized lambda capture
* immediately invoked lambdas
* return value optimization
* guaranteed return value optimization
* initializer_list
* recursive lambdas
* deducing `this`
* recursive functions
* trivially copyable types
* higher order functions
* dangling references
* undefined behavior
* inheritance
* multiple inheritance
* function hiding
* variadic `using` declarations
* scoping / lookup rules
* class template argument deduction
* deduction guides
* algorithms
* ranges
* ``
* virtual member functions
* member function pointers
* special member functions
* member function call syntax
* type erasure
* dynamic vs automatic storage
Missing
* writing own concepts
* type_traits
* operator
* protected
* virtual inheritance
* compilation model
* ODR violations
* preprocessor
* project structure and layout
* the breadth of the standard library
* variable templates
* coroutines
* modules
Alternative title: Why C++ is Insanity
unbelievably great
Great checklist and presentation. Covers almost everything In the language except modules and coroutines. Curiously, there is no array manipulation or memory allocation, and pointers are (happily) thin on the ground.
Others have mentioned other lacunae but, after them, we’re into esotericism like atomics and laundry.
Man! That felt fantastic, and it was quite motivational. :)
Title can be, 20 mins of Self-confidence in C++
Well, I have a little thought too, about std::tuple{};
10:17 - Why std::apply isn't used here? I believe, it would simplify the code, + would make it much, much readable.
I actually didn't think of std::apply, but did in a future episode that is coming up soon. I need to probably do an episode about that.
2:11 "There are some exceptions, of course, and I am going to list those..."
I watched the whole video, and I didn't see exceptions mentioned. 😉
They are the 12 listed at the very end, which lambdas do not directly go into.
@@cppweekly Sorry, I was trying to make a terrible pun about "exceptions, the C++ feature". Of course, I could easily have missed that you _did_ talk about them, and then the joke's on me!
Brilliant !
15:46 what the actual?
My days of applying for an interview where they will ask questions about syntax are over. Kek.
This comes across as satire. Poe’s law in action
Polymorphic clone function, just to add one.
That's kind of covered at the end where I say "make your own std::function implementation" (or whatever)
Yay, back in the day we were only risked to shoot our foot, now we have to watch out for our faces as well. 🤠
Most basic cpp dev: "Cpp is easy"
Cpp: "yeah son, now try to create a generic lamda"
Has anyone ever said that? My approach has always been: if you understand C++ then you understand computers (knowing machine architecture, instruction set and assembler are prerequisites IMHO too). C++ is life-long learning, which is great for educators like, er, Jason.
@@treyquattro I think that before learning C++, it could be taught much better if firstly general concepts of how compilation actually is done in real world, and how CPUs work are taught. So many things started to get their understandable place after learning a bit about these concepts...
good stuff
THREADS!
Hmm, I'm still on C++99 ... And I so happy with this.
Not sure if useful as an idea for a video or even if it happens to other people. I can understand modern c+- but i cant write because older stuff seems easier to me.
Ps. I am c++ dumb but i people still pay me to develop software on other languages, so i suppose i am not the most terrible programmer
🤯
god he speak so slow
UA-cam has playback speed control