Back to Basics: Function and Class Templates - Dan Saks - CppCon 2019

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2019
  • CppCon.org
    -
    Discussion & Comments: / cpp
    -
    Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2019
    -
    Generic programming is a collection of techniques for implementing software components that you can adapt easily for a variety of uses. In C++, templates are the primary tool for generic programming, and they're used throughout the standard library. Templates can be functions or classes, as well as variables or type aliases.
    This session is for C++ programmers who would like to shore up their understanding of templates. It describes many C++ template features and offers insights into how compilers use compile-time information, such as types and values, to process templates.
    This session begins by showing how to define function templates and how call them using explicitly-specified or deduced template arguments. It then covers class templates, including the behavior of static data members, friends, and nested classes appearing in class templates. It explains why template definitions require explicit qualification or the keyword typename in some situations. It presents the different forms of template parameters and corresponding arguments, as well as default arguments. Throughout, it clears up common misunderstandings regarding templates, such as the differences among the mechanisms of instantiation and the different flavors of specialization.
    -
    Dan Saks
    Saks & Associates
    President
    Dan Saks is the president of Saks & Associates, which offers training and consulting in C and C++ and their use in developing embedded systems. Dan used to write the “Programming Pointers” column for embedded.com online. He has also written columns for numerous print publications including The C/C++ Users Journal, The C++ Report, Software Development, and Embedded Systems Design. With Thomas Plum, he wrote C++ Programming Guidelines, which won a 1992 Computer Language Magazine Productivity Award. Dan has taught C and C++ to thousands of programmers around the world. He has presented at conferences such as Software Development, Embedded Systems, and C++ World. He has served on the advisory boards of the Embedded Systems and Software Development conferences. Dan served as secretary of the ANSI and ISO C++ Standards committees and as a member of the ANSI C Standards committee. More recently, he contributed to the CERT Secure C Coding Standard and the CERT Secure C++ Coding Standard.
    -
    Videos Filmed & Edited by Bash Films: www.BashFilms.com *-----*
    Register Now For CppCon 2022: cppcon.org/registration/
    *-----*

ความคิดเห็น • 50

  • @middleverse3838
    @middleverse3838 4 ปีที่แล้ว +19

    We need a Dan Saks for everything.

  • @MarcusAseth
    @MarcusAseth 4 ปีที่แล้ว +68

    He is an excellent teacher, each slide is explained concisely and clearly and he gives you time for the point to sink

  • @user-qy6di9li4w
    @user-qy6di9li4w 2 ปีที่แล้ว +9

    47:31 It is a simple fact about why we need "typename". His way of explanation is very enlightening. I wish I could see it earlier.

  • @keithrobinson2016
    @keithrobinson2016 2 ปีที่แล้ว +10

    Excellent presenter. Clearly has a deep understanding of the subject and conveys the knowledge really well. Shall look out for more of his presentations.

  • @powkung45
    @powkung45 11 หลายเดือนก่อน

    Watching c++ videos makes me appreciate how well TCL in particular uses brackets so nicely, there's no confusion about which relates to what, without overlapping meaning...

  • @parth87x
    @parth87x 2 ปีที่แล้ว +5

    This presentation from Dan Saks, is the best intro to Templates. Thanks a lot.

    • @CppCon
      @CppCon  2 ปีที่แล้ว +1

      Glad you like it!

  • @hpandeymail
    @hpandeymail 3 ปีที่แล้ว +15

    Just few minutes and I am so much confident that he is a proficient teacher .. thanks for sharing your wisdom 🙏

    • @CppCon
      @CppCon  3 ปีที่แล้ว +2

      Glad to hear that

  • @nicolasjochem1814
    @nicolasjochem1814 4 ปีที่แล้ว +8

    i love it, one is really rewarded for concentrated listening here because he grasps it so well in "each sentence"

  • @yasamanderiszadeh902
    @yasamanderiszadeh902 ปีที่แล้ว +1

    Fantastic talk! Was able to not only teach one topic very clearly, but also touch on other topics of C++ programming without confusing and distracting the audience.

    • @CppCon
      @CppCon  ปีที่แล้ว

      Thank you so much for your comment!

  • @kamilziemian995
    @kamilziemian995 ปีที่แล้ว

    Back to Basics is the best learning material for C++ that I found on the TH-cam.

    • @CppCon
      @CppCon  ปีที่แล้ว +1

      Thank you for letting us know that you find the Back to Basics track very educational.

  • @yashtrikannad518
    @yashtrikannad518 4 ปีที่แล้ว +9

    One of the best talks I've heard on templates! Very concisely explained

  • @kulakulagundi
    @kulakulagundi 4 ปีที่แล้ว +4

    Excellent, I am his fan since 2001 when I started reading his articles in ESP magazine.

  • @gregwoolley
    @gregwoolley 3 ปีที่แล้ว +9

    Nice talk, well explained, thank you. Thank you also CppCon for providing these great videos, much appreciated!

  • @chrisshyi8999
    @chrisshyi8999 4 ปีที่แล้ว +12

    Excellent presentation on templates, I learned a lot!

  • @ian3084
    @ian3084 4 ปีที่แล้ว +2

    These lectures are invaluable. Nice presentation.

  • @jvsnyc
    @jvsnyc 3 ปีที่แล้ว +6

    This is really good. There are a lot of talks and blogs, etc. etc. about templates which would be great if you have already watched this one and learned everything in it, but are terrible icy lakes to jump into from scratch.

  • @oxioxp
    @oxioxp 4 หลายเดือนก่อน

    Excellent teacher and clear explanation thanks!

  • @user-zp3nd6ht8v
    @user-zp3nd6ht8v 4 ปีที่แล้ว +2

    Very good tutorial, I can see his passion for it. Thanks, bro!

  • @MikeMitterer
    @MikeMitterer 3 ปีที่แล้ว +4

    Boy, what a great presentation!

    • @CppCon
      @CppCon  3 ปีที่แล้ว +1

      Glad you liked it!

  • @anthonyrocha8075
    @anthonyrocha8075 4 ปีที่แล้ว +1

    Very clear explanation of a tricky feature.

  • @perfumedsea
    @perfumedsea 4 ปีที่แล้ว +3

    Very good presentation on template basics. I liked how typename is introduced part and the specialization materials. I found most tutorials will skip these basics.

  • @sizur
    @sizur 4 ปีที่แล้ว +2

    This presenter is superb!

  • @nukemate
    @nukemate 3 ปีที่แล้ว +2

    It's really good explanation. Covered all basic aspects! Thanks!

    • @CppCon
      @CppCon  3 ปีที่แล้ว

      Glad it was helpful!

  • @pawanadhikari110
    @pawanadhikari110 4 ปีที่แล้ว +1

    Clear and concise

  • @PerisMartin
    @PerisMartin 4 ปีที่แล้ว +1

    If I ever meet Mr Saks on the street I'll give him a hug

  • @vincezzz9757
    @vincezzz9757 2 ปีที่แล้ว +2

    clear and concise. thank you!

    • @CppCon
      @CppCon  2 ปีที่แล้ว

      You're welcome!

  • @Poti221
    @Poti221 3 ปีที่แล้ว +4

    Amazing!

    • @CppCon
      @CppCon  3 ปีที่แล้ว

      Thanks!

  • @vhlk
    @vhlk 2 ปีที่แล้ว

    Awesome video!!!!

    • @CppCon
      @CppCon  2 ปีที่แล้ว +1

      Glad you enjoyed it

  • @IdanBanani
    @IdanBanani 3 ปีที่แล้ว

    great!

  • @carlschumann
    @carlschumann ปีที่แล้ว

    1:01:15 terminology specialization and instantiation

  • @ZackDia-Ptr
    @ZackDia-Ptr ปีที่แล้ว

    After two presentations for this Prof, i am starting to see oop more clearly... thanks!

  • @johnshaw6702
    @johnshaw6702 3 ปีที่แล้ว +1

    It could use improvement, but not bad. I did learn a couple things about modern C++, that I did not know about.
    The piece towards the end about comparing those character array pointers was not correct though. The stack starts at a high address and each subsequent item pushed on it has a lower address. So the address of array starting with 'N' is actually higher. As a concept explanation it my not seem important, but in the real world it can be very important.

    • @jamesburgess9101
      @jamesburgess9101 2 ปีที่แล้ว +2

      Fun fact: standard C++ (and C) deliberately say absolutely nothing about the direction of the stack. It can be either and some architectures, like ARM, it is selectable. If you think knowing the direction of the stack is important (which it is) you will also definitely want to know this: the compiler in standard C++ (and C) is at liberty to rearrange your variables on the stack! The order you write them in your source code is not the order it has to allocate them.
      We should forget the stack though, that example did not specifiy if the pointers where even on the stack and that certainly was not the point of the example.

  • @lck5217
    @lck5217 4 ปีที่แล้ว +1

    56:58
    Functions have external linkage by default, I think we can do the same with explicit specialization declaration like this:
    main.cpp
    // ****************
    #include "f.hpp"
    template void f();
    int main()
    {
    f();
    return 0;
    }
    // ****************
    f.cpp
    // ****************
    #include "f.hpp"
    template void f()
    {
    cout

  • @shrivatsankchari1729
    @shrivatsankchari1729 2 ปีที่แล้ว

    58:19 wouldn't that throw an error? Early on in the presentation he said return types are not deduced and need to be specialized at declaration.

  • @rafalmichalski4893
    @rafalmichalski4893 4 ปีที่แล้ว +1

    Would it compile from slide 85 ? npos is typically size_t constant with max or -1 (e.g. for std::string) so we are trying to init pointer to size_t (typename T::size_type *) with size_t constant(T::npos) here I guess. But I might be wrong of course.

  • @antonfernando8409
    @antonfernando8409 2 ปีที่แล้ว

    Nice and simple, now I understand template, just that him checking his time so often is kind of odd lol.

  • @wenhailong6192
    @wenhailong6192 ปีที่แล้ว

    where the slide