C++ Weekly - Ep 348 - A Modern C++ Quick Start Tutorial - 90 Topics in 20 Minutes

Поделиться
HTML-код
  • Опубликовано: 15 сен 2024
  • ☟☟ Awesome T-Shirts! Sponsors! Books! ☟☟
    Upcoming Workshop: C++ Best Practices, NDC TechTown, Sept 9-10, 2024
    ► ndctechtown.co...
    Upcoming Workshop: Applied constexpr: The Power of Compile-Time Resources, C++ Under The Sea, October 10, 2024
    ► cppunderthesea...
    Episode notes: github.com/lef...
    T-SHIRTS AVAILABLE!
    ► The best C++ T-Shirts anywhere! my-store-d16a2...
    WANT MORE JASON?
    ► My Training Classes: emptycrate.com/...
    ► Follow me on twitter: / lefticus
    SUPPORT THE CHANNEL
    ► Patreon: / lefticus
    ► Github Sponsors: github.com/spo...
    ► Paypal Donation: www.paypal.com...
    GET INVOLVED
    ► Video Idea List: github.com/lef...
    JASON'S BOOKS
    ► C++23 Best Practices
    Leanpub Ebook: leanpub.com/cp...
    ► C++ Best Practices
    Amazon Paperback: amzn.to/3wpAU3Z
    Leanpub Ebook: leanpub.com/cp...
    JASON'S PUZZLE BOOKS
    ► Object Lifetime Puzzlers Book 1
    Amazon Paperback: amzn.to/3g6Ervj
    Leanpub Ebook: leanpub.com/ob...
    ► Object Lifetime Puzzlers Book 2
    Amazon Paperback: amzn.to/3whdUDU
    Leanpub Ebook: leanpub.com/ob...
    ► Object Lifetime Puzzlers Book 3
    Leanpub Ebook: leanpub.com/ob...
    ► Copy and Reference Puzzlers Book 1
    Amazon Paperback: amzn.to/3g7ZVb9
    Leanpub Ebook: leanpub.com/co...
    ► Copy and Reference Puzzlers Book 2
    Amazon Paperback: amzn.to/3X1LOIx
    Leanpub Ebook: leanpub.com/co...
    ► Copy and Reference Puzzlers Book 3
    Leanpub Ebook: leanpub.com/co...
    ► OpCode Puzzlers Book 1
    Amazon Paperback: amzn.to/3KCNJg6
    Leanpub Ebook: leanpub.com/op...
    RECOMMENDED BOOKS
    ► Bjarne Stroustrup's A Tour of C++ (now with C++20/23!): amzn.to/3X4Wypr
    AWESOME PROJECTS
    ► The C++ Starter Project - Gets you started with Best Practices Quickly - github.com/cpp...
    ► C++ Best Practices Forkable Coding Standards - github.com/cpp...
    O'Reilly VIDEOS
    ► Inheritance and Polymorphism in C++ - www.oreilly.co...
    ► Learning C++ Best Practices - www.oreilly.co...

Комментарии • 85

  • @darkmagic543
    @darkmagic543 Год назад +59

    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

    • @_Omni
      @_Omni Год назад +9

      empty base optimization

    • @volchonokilliR
      @volchonokilliR Год назад

      just a little bonus >w

  • @treyquattro
    @treyquattro Год назад +49

    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!

  • @hagenmuller4568
    @hagenmuller4568 Год назад +9

    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😁

    • @polardevelop
      @polardevelop Год назад

      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)

  • @cppweekly
    @cppweekly  Год назад +19

    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.

  • @PedroOliveira-sl6nw
    @PedroOliveira-sl6nw Год назад +9

    I am amazed at myself that at 13:00 I actually thought about ordering, size of lambdas JUST before you mentioned it. Feeling proud.

    • @cppweekly
      @cppweekly  Год назад +5

      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.

  • @milosko1616
    @milosko1616 Год назад +15

    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

    • @coder2k
      @coder2k Год назад

      I guess that will never change....feel you :D

  • @fcolecumberri
    @fcolecumberri Год назад +7

    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.

  • @blaisofotso3439
    @blaisofotso3439 Год назад +2

    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 .

    • @cppweekly
      @cppweekly  Год назад +4

      I've tried to put together an ordered playlist for "learning" topics ruclips.net/p/PLs3KjaCtOwSY34fFKyhOFovFlB7LikDwe

  • @TheSulross
    @TheSulross Год назад +6

    a booklet could be fashioned around this presentation and it would make a nice companion quick reference - kudos for this nifty angle of attack

    • @cppweekly
      @cppweekly  Год назад +1

      You might check out this one: leanpub.com/cpplambda I have not read it, but it should have a fair bit of overlap.

    • @TheSulross
      @TheSulross Год назад +1

      @@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

  • @ilciavo
    @ilciavo Год назад +4

    90 shots of C++ Espresso

  • @darckangenoir
    @darckangenoir Год назад +6

    move semantic and forwarding/universal ref

  • @PedroOliveira-sl6nw
    @PedroOliveira-sl6nw Год назад +9

    You left out multithreading and maybe the memory model (?)

    • @johanngerell
      @johanngerell Год назад +1

      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"

    • @PedroOliveira-sl6nw
      @PedroOliveira-sl6nw Год назад +3

      @@johanngerell sure. He also asked to comment things he might had left out. =D

    • @johanngerell
      @johanngerell Год назад +1

      @@PedroOliveira-sl6nw fair enough :)

  • @thestarinthesky_
    @thestarinthesky_ Год назад +1

    @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?

    • @cppweekly
      @cppweekly  11 месяцев назад +1

      Very intentional - `this` always refers to the containing object that the lambda was created in.

  • @tonygreenberg7441
    @tonygreenberg7441 Год назад +3

    Friend functions?

  • @johnhsu5459
    @johnhsu5459 Год назад +1

    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..

    • @xorbe2
      @xorbe2 Год назад +1

      You want to look up "C++ deduction guide" which guides from ctor to template params.

  • @danielrhouck
    @danielrhouck Год назад +1

    My favorite feature you didn’t cover, which can apply to lambdas in various ways: concepts and constraints.

    • @cppweekly
      @cppweekly  Год назад +1

      I touch on it at 8:42 briefly.

    • @danielrhouck
      @danielrhouck Год назад

      @@cppweekly Oops, you did, I missed that.

  • @tonybalinski2398
    @tonybalinski2398 Год назад +2

    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.

  • @Chris-yw5is
    @Chris-yw5is Год назад +4

    exceptions should be easy to add to the list as well

  • @CharlesHogg
    @CharlesHogg Год назад +1

    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.

    • @cppweekly
      @cppweekly  Год назад

      I did miss designated initializers, you're right

  • @dimitrilesnoff468
    @dimitrilesnoff468 3 месяца назад +1

    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

  • @auric88
    @auric88 11 месяцев назад

    explicit lambda templates were added in C++20, not in C++17

  • @Omnifarious0
    @Omnifarious0 Год назад +1

    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.

    • @dascool3st
      @dascool3st Год назад

      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?

    • @corpseopera
      @corpseopera 11 месяцев назад

      @@dascool3st did you find some info about it yet?

  • @von_nobody
    @von_nobody Год назад +1

    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.

    • @cactus-man
      @cactus-man Год назад

      And?

    • @cppweekly
      @cppweekly  Год назад +1

      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.

    • @von_nobody
      @von_nobody Год назад

      @@cppweekly yup, most fun experiment I make was creating Stack Turing Machine purely using template metaprograming :D

  • @rolandinnamorato1953
    @rolandinnamorato1953 Год назад +2

    Alternative title: Why C++ is Insanity

  • @CharlesHogg
    @CharlesHogg Год назад +1

    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. 😉

    • @cppweekly
      @cppweekly  Год назад

      They are the 12 listed at the very end, which lambdas do not directly go into.

    • @CharlesHogg
      @CharlesHogg Год назад

      @@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!

  • @MegaCashB
    @MegaCashB Год назад +2

    How are you typing both in the void lambda() and the struct Lambda() at the same time? what sorcery is this @ 4:21?

    • @ajinkyakamat7053
      @ajinkyakamat7053 Год назад +7

      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.

  • @userrand4900
    @userrand4900 Год назад

    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) ?

    • @cppweekly
      @cppweekly  Год назад

      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.

    • @userrand4900
      @userrand4900 Год назад

      @@cppweekly thanks. What are the guarantees that might be violated with delegation?

  • @Faris-1900
    @Faris-1900 Год назад

    Last time I used C++ seriously was almost 10 years ago. How to grasp all those new concepts? Any advice of a good reference?

    • @cppweekly
      @cppweekly  Год назад +3

      I tend to recommend "A Tour of C++" which is linked in the video description.

  • @kimhyunpil
    @kimhyunpil Год назад

    unbelievably great

  •  Год назад +1

    Yay, back in the day we were only risked to shoot our foot, now we have to watch out for our faces as well. 🤠

  • @paulcg7566
    @paulcg7566 Год назад +2

    Most basic cpp dev: "Cpp is easy"
    Cpp: "yeah son, now try to create a generic lamda"

    • @treyquattro
      @treyquattro Год назад +1

      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.

    • @volchonokilliR
      @volchonokilliR Год назад

      @@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...

  • @jobinthomas6372
    @jobinthomas6372 Год назад

    How are you typing so fast ? What keyboard are you using ?

  • @TheMR-777
    @TheMR-777 Год назад +6

    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
      @cppweekly  Год назад +2

      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.

  • @drygordspellweaver8761
    @drygordspellweaver8761 Год назад +1

    This comes across as satire. Poe’s law in action

  • @numv2
    @numv2 Год назад

    Brilliant !

  • @tetsuoshiva
    @tetsuoshiva Год назад

    My days of applying for an interview where they will ask questions about syntax are over. Kek.

  • @michelchaghoury9629
    @michelchaghoury9629 Год назад

    I Am new to C++ this channel is amazing but were do i start?

    • @cppweekly
      @cppweekly  Год назад

      somewhere around episode 5 I think :D

  • @krofikS4
    @krofikS4 Год назад +2

    Polymorphic clone function, just to add one.

    • @cppweekly
      @cppweekly  Год назад +2

      That's kind of covered at the end where I say "make your own std::function implementation" (or whatever)

  • @biggysmith
    @biggysmith Год назад

    good stuff

  • @cavesalamander6308
    @cavesalamander6308 Год назад

    Hmm, I'm still on C++99 ... And I so happy with this.

  • @i_am_acai
    @i_am_acai Год назад

    Could you explain 3:32?

    • @cppweekly
      @cppweekly  Год назад +1

      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"

    • @userrand4900
      @userrand4900 Год назад

      ​@@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.

  • @S1lentSt0rm
    @S1lentSt0rm 8 месяцев назад

    15:46 what the actual?

  • @ratman-gimmecheez
    @ratman-gimmecheez Год назад

    THREADS!

  • @muhammadharris4470
    @muhammadharris4470 Год назад

    🤯

  • @Fareoneo
    @Fareoneo Год назад

    god he speak so slow

    • @cppweekly
      @cppweekly  Год назад +2

      RUclips has playback speed control