How to use CLASS TEMPLATES, type traits, partial and full class template specialization

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ธ.ค. 2024

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

  • @ChimiChanga1337
    @ChimiChanga1337 7 หลายเดือนก่อน +2

    BRUH. The universe might actually be alive. I have been struggling to understand templates and was a bit sad that you didn't drop a video on them. Now here you are. FTW.

  • @pitri_hub
    @pitri_hub 7 หลายเดือนก่อน +3

    Template meta programming with (partial) specialization is such a wildly different language than to "regular" C++. And it's such an incredibly deep rabbit hole.
    Interestingly enough, my knowledge about this topic really helped to understand Haskell a lot better during the semester it has been taught in. The signature pattern matching in partial specializations is almost identical to how Haskell functions are overloaded for their use cases.
    C++ really helps to become a better programmer, because it exposes the user to a lot more concepts than certain other languages that deem certain mechanisms to low-level or dangerous to be exposed to the programmer. But seeing how C++ was helpful for such an unrelated language with very different paradigms was just wild. :D

    • @CodeForYourself
      @CodeForYourself  7 หลายเดือนก่อน +1

      Thanks for sharing! Did not think of this parallel!
      I have only played a little with functional language but yes, the recursiveness of template meta programming I guess is what makes the experiences similar.

    • @harleyspeedthrust4013
      @harleyspeedthrust4013 6 หลายเดือนก่อน +2

      I came back to c++ after spending some time with ocaml, rust, and idris, and everything was so much easier. This template stuff makes a lot more sense now and these videos are really good

    • @CodeForYourself
      @CodeForYourself  6 หลายเดือนก่อน +1

      @harleyspeedthrust4013 thank you so much! Hope you keep enjoying the videos coming next! 🙌

  • @Maximus98245
    @Maximus98245 5 หลายเดือนก่อน +1

    Great video! One thing that bothered me a bit was usage of " to specify template parameter. The parameter has nothing to do with class, it could be just as easily called , the word "class" gives a wrong impression, at least to me. Thanks!

    • @CodeForYourself
      @CodeForYourself  5 หลายเดือนก่อน

      Ok, I agree with you that ClassT doesn’t hit the mark. What I prefer doing generally (when I cannot use concepts) is to give the template parameters meaningful names. Considering that this function is very illustrative and doesn’t really have a proper purpose it is hard to pick such a template parameter name, meaning the one that actually makes sense. So here I picked the ClassT as a substitute but I agree that it is a bit stupid and if I would have thought longer about it I probably would have just used T here. Thanks for your comment!

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

      For the win, my man

  • @DimaLyganov
    @DimaLyganov 7 หลายเดือนก่อน

    Nice T-short, man!