Back to Basics: Templates in C++ - Nicolai Josuttis - CppCon 2022

Поделиться
HTML-код
  • Опубликовано: 5 фев 2025
  • cppcon.org/
    ---
    Back to Basics: Templates in C++ - Nicolai Josuttis - CppCon 2022
    github.com/Cpp...
    Templates are among the most powerful features of C++, but they remain misunderstood and underutilized, even as the C++ language and development community have advanced. This talk shows when and how to use modern templates to build software that's cleaner, faster, more efficient, and easier to maintain. We will cover all basic aspects of templates you have to know when programming generic code in Modern C++
    ---
    Nicolai Josuttis
    Nicolai Josuttis is well-known in the community for his authoritative books and talks. For more than 20 years he has been a member of the C++ Standard Committee. He is the author of several worldwide best-sellers, including:
    C++20: The Complete Guide
    C++17: The Complete Guide
    C++ Move Semantics: The Complete Guide
    The C++ Standard Library: A tutorial and Reference
    C++ Templates: The Complete Guide (w/ David Vandevoorde & Doug Gregor)
    __
    Videos Filmed & Edited by Bash Films: www.BashFilms.com
    RUclips Channel Managed by Digital Medium Ltd events.digital...
    #cppcon #programming #template

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

  • @cobaltno51
    @cobaltno51 12 дней назад +1

    As someone looking in from the outside it is absolutely insane that it took until C++20 to implement type constraints for templates. The deepest respect to all programmers that were able to wield templates correctly before that change. What a crazy language.

  • @thestarinthesky_
    @thestarinthesky_ 3 месяца назад +2

    Thanks CppCon for uploading videos here. so much appreciate it. Couldn't be more proud of this great community.

  • @moderncpp
    @moderncpp 2 года назад +33

    Great talk. I believe that understanding templates reveals most of the C++ programming language.

  • @parthapratimmukherjee
    @parthapratimmukherjee 10 месяцев назад +1

    Its amazing how Nico can make extremely complex topics approachable. I bought all his books!

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

    You're brilliant! I LOVE your amazing books and you're my role model. Thanks for contributing to the world of C++

  • @wigglyk2796
    @wigglyk2796 2 года назад +13

    Wow the master himself. His book on templates is excellent. Thanks for this video.

    • @CppCon
      @CppCon  2 года назад +1

      Glad to hear that you enjoyed this presentation!

  • @deadbird99
    @deadbird99 2 года назад +9

    Hands down the best templates course I've ever had. Thanks!!

  • @superscatboy
    @superscatboy 2 года назад +17

    Nico is a great speaker, I've been looking forward to this one!

  • @richardvonlehe4581
    @richardvonlehe4581 2 года назад +3

    Well done! Engaging throughout.

  • @prafulsrivastava7684
    @prafulsrivastava7684 2 года назад +5

    This is exactly what I was looking for! Great talk!

  • @OptimusVlad
    @OptimusVlad 2 года назад +5

    Wow, this is trippy. Didn't know this was a thing:
    if constexpr (requires {coll.push_back(val);})

  • @brandonz6121
    @brandonz6121 2 года назад +3

    A truly insightful talk!

  • @stevea.b.9282
    @stevea.b.9282 6 месяцев назад

    Fantastic talk, thank you, I'm just starting to learn templates and this helped immensely, many thanks.

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

    That's a pure pleasure to listen to the prelection like this. Thank you!

  • @Tony-tu8uz
    @Tony-tu8uz 2 года назад +1

    Very good! Thank you for the talk!

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

    thank you. even better the second time around! : )

  • @sky_is_the_limit_13
    @sky_is_the_limit_13 5 месяцев назад

    Great talks! I love your books! You're absolutely amazing. BTW, I am looking for "Back to Basics 2022" playlist but couldn't find it.

  • @the_real_foamidable
    @the_real_foamidable 2 года назад +21

    Very cool talk. Always good to recapitulate the basics - there are to many things we use without understanding the underlying tech and history.
    BTW: Where can I get this awesome T-Shirt?

  • @yowadup1000
    @yowadup1000 2 года назад

    Looks pretty exciting!

  • @NickEnchev
    @NickEnchev 2 года назад

    Excellent talk, thank you.

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

    Great talk

  • @xFabi99
    @xFabi99 2 года назад

    Templates are pretty awesome now, as is this talk ;)

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

    Super Sir, impressed :)

  • @xudongsun
    @xudongsun 2 года назад +2

    love his tshirt. where can I get one?

  • @guillermotomasini
    @guillermotomasini Месяц назад

    thanks

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

    We need an "if compiles{" expression that takes the first branch if the code in that branch compiles 😅

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

      The much needed. We need better metaprogramming.

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

    Great talk man!

  • @paulselormey7862
    @paulselormey7862 2 года назад

    Josuttis, thank you.

  • @bareminimum-mrtz
    @bareminimum-mrtz 5 месяцев назад

    Thankyou so much !!

  • @ZackDia-Ptr
    @ZackDia-Ptr Год назад

    Good stuff...

  • @MalcolmParsons
    @MalcolmParsons 2 года назад

    35:46 std::complex is only specified for float, double and long double, not for int.

  • @Jam18123
    @Jam18123 2 года назад

    Very useful

  • @sanjaygatne1424
    @sanjaygatne1424 2 года назад

    nice talk.
    i had one query on slide no.31, why recursive call to "if" statement when you know number of var args. why not "range for".

    • @thepiratepeter4630
      @thepiratepeter4630 2 года назад

      You can't iterate on an argument pack like you would do with a container, because the types of the various elements could be different.

    • @thepiratepeter4630
      @thepiratepeter4630 2 года назад

      In his specific example you could avoid recursion using a fold expression.

    • @atib1980
      @atib1980 2 года назад

      There isn't a foreach construct in C++ that would allow you to loop through a range of data of different data types at runtime. C++ foreach works on only those data types that have implemented the basic input iterator related operators defined by the requirements of input iterators (begin(), end() operator++() and operator*). In the example on slide 31 you just want to print every fn argument on a separate line (where fn argument is of a certain type for which ostream& operator

  • @djupstaten2328
    @djupstaten2328 2 года назад +2

    This is why a TypeEval function is screaming to be created. I am 100% certain the std::people can create a better one than I can. Typeid() doesn't actually consider a tuple of string/int/string the same type as a tuple of variant/variant/map as the same types so there is no secure way to funnel them into whatever place or process they need to be. A bool function is totally fine as long as it is general (i.e. one container type instance should match with another, and with its type-name, regardless of their particular flavor of chaos inside). Knowing everything at compile time is neither realistic nor creatively workable. "Strongly typed" needs to not just be a begrudging neurosis or a religious mantra but also lead to supplying the proper tools for the coder to secure this strength on his or her end.

  • @gnerkus
    @gnerkus 2 года назад

    Interesting talk, though not as 'basic' as I assumed.
    It would have been helpful if the speech bubbles were removed; the code in the speech bubbles could have been placed side-by-side with the code on the left. For example, at 4:18, the text in the speech bubble could have been replaced with the code on the left but with "T" and "typename" swapped out for "CustomType" and "class". The explanation need not change.
    4:16 "...use a better name, like CustomType as shown in the example on the right".
    3:37 "...can be replaced by class, as you can see in the example on the right..."
    Edit: I just noticed the speech bubbles do help as annotations in other slides.

  • @BiddutMitra
    @BiddutMitra 2 года назад

    C with better structure, which is c++.

  • @vasylvoina6663
    @vasylvoina6663 2 года назад

    I call function templates for 145 000 different types, so I end up with 145 000 functions generated. Wow, really nice feature.

  • @googledeus
    @googledeus Год назад +8

    Keep C++ away from stupid politics

  • @paulchamberlain7942
    @paulchamberlain7942 3 месяца назад

    pReality = (UnconditionalSurrender *)pVictoryPlan;

  • @ПетрПроценко
    @ПетрПроценко 2 месяца назад

    BTW if you stop Putin (i.e. perform a successful coup in Russia) things are guaranteed to take a turn for the worse. If you are as invested in political situation in Russia as I am an expert in templates in C++ (I know that < > now does not always mean "include a library from a standard location of all libraries") maybe you should consider first studying, then preaching?

  • @__hannibaalbarca__
    @__hannibaalbarca__ 2 года назад +18

    _CppCon_ please keep politic out.

    • @toxic_champ
      @toxic_champ 5 месяцев назад

      they can't, there is "con" in channel's title. So following the agenda is what they have to do

    • @rahulc480
      @rahulc480 4 месяца назад +1

      Just to understand, what are you talking about

    • @nikon800
      @nikon800 2 месяца назад +1

      @@rahulc480 See top left corner of the slide.

    • @Musikvidedo
      @Musikvidedo 3 дня назад +1

      @@__hannibaalbarca__ not speaking up is just as political as speaking up. It's just a matter of whose side you're on ;)