Back to Basics: Lambdas - Nicolai Josuttis - CppCon 2021

Sdílet
Vložit
  • čas přidán 31. 05. 2024
  • cppcon.org/
    github.com/CppCon/CppCon2021
    ---
    Lambdas, introduced with C++11, are used everywhere in modern C++ programming. While their use looks pretty straightforward, you should know about some details that help you to benefit from their full power.
    This session teaches lambdas in detail. Based on the basic principles, it motivates and explains why lambdas are more powerful than functions and how to use them to benefit from that.
    ---
    Nicolai Josuttis
    Nicolai Josuttis (www.josuttis.com) is well known in the programming community because he not only speaks and writes with authority (being the (co-)author of the world-wide best sellers The C++ Standard Library (www.cppstdlib.com), C++ Templates (www.tmplbook.com), C++17 - The Complete Guide (www.cppstd17.com), C++ Move Semantics - The Complete Guide (www.cppmove.com), and SOA in Practice), but is also an innovative presenter, having talked at various conferences and events.
    He has been an active member of the C++ standards committee for more than 20 years.
    ---
    Videos Streamed & Edited by Digital Medium: online.digital-medium.co.uk
    Register Now For CppCon 2022: cppcon.org/registration/
  • Věda a technologie

Komentáře • 29

  • @chudchadanstud
    @chudchadanstud Před 5 měsíci +2

    Man I love this guy's talks/tutorials. Very simple very clear.

  • @linuxgaminginfullhd60fps10
    @linuxgaminginfullhd60fps10 Před 2 lety +16

    Nice, so many tiny details I didn't know or was confused about.

  • @sambatgoson6923
    @sambatgoson6923 Před 2 lety +10

    clear , clean and powerful. very good tutorial, easy to understand in a few minutes. looking forward to see next.

  • @flamewingsonic
    @flamewingsonic Před 2 lety +6

    13:13 "Case-insensitive sorting is always a little bit tricky in C++" Just to hammer his point home, passing a raw char directly to std::toupper as he does in the slideware is actually wrong... you have to cast it to unsigned char before passing to std::toupper or you can run into undefined behavior on implementations where char is signed. But, you know, slide code and all...

  • @FORTDavid
    @FORTDavid Před 10 měsíci +1

    Thank you for the talk, I read many things about lambdas in C++, but all the papers I had read don't explain the internals (class object with () operator) and without that it just looks like magic and you don't get all the implications of lambdas. So big thanks you for the talk.

    • @maxwen6447
      @maxwen6447 Před 8 měsíci

      i agree. I am trying to work through the code of these examples but it's more difficult since so much code was left out.

  • @irfanulhaq8523
    @irfanulhaq8523 Před 2 lety +4

    Explained well. Thanks for the quality content.

  • @oschonrock
    @oschonrock Před 2 lety

    Very good as usual Nicolai. Slide 10: The "toupper" lambda should take "unsigned chars" to avoid UB in ? Same on slide 11...

  • @neilharvey94
    @neilharvey94 Před 3 měsíci

    I recall using the STL long before C++11, back in the late 90s.

  • @FroL_Onn
    @FroL_Onn Před 2 lety +2

    What a great talk!

  • @gowrishankars9743
    @gowrishankars9743 Před 2 lety

    Thanks for the session. Neatly explained..

  • @rahultandon9749
    @rahultandon9749 Před 3 měsíci

    I have yet to remove the confusion between lambdas vs. generics vs. templates

  • @gunjankumar1943
    @gunjankumar1943 Před 9 měsíci +1

    Where can I get the slides of the talk?

  • @guoliangwang4826
    @guoliangwang4826 Před 2 lety +1

    Great talk!!! if i can get pdf file somewhere?

  • @skeleton_craftGaming
    @skeleton_craftGaming Před 5 měsíci

    I think the statement" My life would be better if my co-workers knew more C++" is true for everyone...

  • @shailendrarajput6219
    @shailendrarajput6219 Před rokem

    Easy to understanding . Looking for next to meet.

  • @dos350
    @dos350 Před 2 lety +1

    thanks sir, great presentation

    • @CppCon
      @CppCon  Před 2 lety +1

      You are most welcome

  • @EgorChebotarev
    @EgorChebotarev Před 3 měsíci

    interesting and useful

  • @chiefsittingstill6061
    @chiefsittingstill6061 Před 6 měsíci

    Working through this in an IDE and the ranges lexicographical sort on slide 11 was vexing me for a while, but got it working. Slide code error... he's missed a semi-colon out after the return statement. If you amend the example to get it as the following, it will work:
    std::ranges::sort(
    v2, // Range to sort
    [](const std::string& s1, const std::string& s2) { // Sort criterion
    auto toUpper = [](char c) { return std::toupper(c); };
    return std::ranges::lexicographical_compare(
    s1, // String as 1st range
    s2, // String as 2nd range
    std::less{}, // Compare criterion
    toUpper, // Projection for s1 element
    toUpper); // Projection for s2 element
    }); // End of sort statement

  • @hossamalzomor3311
    @hossamalzomor3311 Před rokem

    In slide 11 we have two strings while lambda argument is char!

  • @meowsqueak
    @meowsqueak Před rokem

    Lambdas are cool-n-all, but very difficult to unit test. Apart from tiny lambdas to std algorithms within testable functions, I still prefer explicit function objects and function templates because of this.

  • @CuriousCauliflowerX
    @CuriousCauliflowerX Před rokem

    I appreciate how he owns the fact that C++ is partially his fault. Self awareness majority of the commitee lacks.

  • @Sajal89
    @Sajal89 Před rokem +1

    I couldn't understand the problem with having a function, why Lambdas? rewriting again and again may cause errors to creep in. testability.. it invalidates all basis of having a modular design.

    • @rahultandon9749
      @rahultandon9749 Před 2 měsíci

      Is it ok to perceive lambdas calculus as symbolic math

  • @MrZapper1960
    @MrZapper1960 Před 2 lety +1

    “It’s partially all my fault”

  • @TesterAnimal1
    @TesterAnimal1 Před 2 lety +2

    Awesome.
    Catching up with JavaScript! 😂

    • @yifanyang6400
      @yifanyang6400 Před 2 lety

      They are really like javascript features in C++, which looks kinda scaring to me

    • @PixelThorn
      @PixelThorn Před 2 lety +8

      C++ introduced lambdas in 2011, Javacript in 2015 - if anything JavaScript is catching up to C++