TEMPLATES in Modern C++

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

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

  • @Entropytheory
    @Entropytheory ปีที่แล้ว +90

    Honestly, your C++ videos are genuinely amazing

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

    Fun fact, templates are possible even in C89, I'm actually using them to transform my custom library into something more maintainable than what I had before after realising how to produce debuggable templates via #include, the thing that was treated as a nuisance before (being included each time #include was used rather than just once) turned out to be the key to templates in C89 :)

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

    These CPP videos are just mind-blowing.

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

    im a CS student learning c++ and I also love csgo. your channel is about to become my favorite thing ever

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

    C++ is indeed a complex *langauge*

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

      i can't spell ok :(

  • @daiki-starsation
    @daiki-starsation ปีที่แล้ว +8

    Nice video as always man! Keep up the great work!

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

    Such a great video! I love your minimal style too! There is just a small nitpick about inline. It does not really behave like static. Static mostly makes things have internal linking while inline actually does the opposite: it forces external linkage. Both help to avoid linker errors but in very different ways. Otherwise, I really like your video, keep up the good work!

  • @CoolModderJaydonX
    @CoolModderJaydonX 4 หลายเดือนก่อน +1

    Keep in mind, with Python, you can actually specify what type a variable, parameter, or function is. For example:
    a: int = 6 # a is an integer
    b: str = "Hello!" # b is a string
    a = b[0] # error
    def add(a: float, b: float) -> float:
    return a + b

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

      Absolutely.
      Type hints are one of my favorite additions to Python3. They make using/navigating libraries so much easier, and I make sure to use them everywhere for medium to large projects.
      I wish they provided a performance increase though...
      Thanks for the comment and have a great day!

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

    One thing I hate about templates is it is counter intuitive to how we learn c++. Specifically we are taught to separate the declaration from the implementation to keep things organized but with templates this cant easily be done with out explicit template instantiation or some weird trampoline header

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

    great job as always💯

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

    One of the best features of any language. Sadly, there's no templates in C and we have to write our own ones which are not ideal

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

    Keep it up cazz 🦾 very helpful

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

    cant wait for the more in-depth kernel video

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

    Really good video with great introduction, explanation and examples. You're doing an amazing job!

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

      Thank you 🥹

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

    This was great! Looking forward to more modern cpp lessons

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

    Once again, great video Cazz

  • @jin-yw4tb
    @jin-yw4tb ปีที่แล้ว +1

    i dont know a good way to start learning c++ but your videos definitely seem like an invaluable asset that ill need once i start understanding the basics.

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

      Yea I’ve been learning C++ for a week and some change and I feel like this will be very useful later on in my programming career

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

      @@devonharvey8414 it will be

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

      @@iiferedoncXclan yesss cause I love C++, it’s so fun and cool, just wish I had more project ideas to work on for my current skill level

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

    SFINAE is actually not that hard to understand. VERY simplified example:
    Let's assume we have an overloaded template function called "add()" and a regular function with the same name. We call the add-function with parameters that cannot be used in the template version (think concatenating strings versus adding integers for instance). This should usually give us a compile error because the template is not able to be resolved, despite the template being a generic. In this case template substitution failed, but it is not an error since we have an overload resolution for the function.

    • @user-dh8oi2mk4f
      @user-dh8oi2mk4f ปีที่แล้ว

      Wouldn't the template add function on its own handle the strings and integers just fine, since templates are fully resolved at compile time?

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

      @@user-dh8oi2mk4f To be fair my example was a bit bad.
      In general SFINAE is usually applied to types and objects. Let's say we have an add function that takes a regular type T and an add function that takes an object F::num.
      By calling add(10) we would get a compile time error because int::num doesn't exist. The compiler is able to recognize the overload though and generate proper code.

  • @SurflFilms
    @SurflFilms 9 หลายเดือนก่อน

    this needs more views

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

    I’ve never even touched c++ but I think I understood most of what the video was about

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

    Python is not weakly typed, but strongly and dynamically. JavaScript is weakly typed.
    Weakly typed means that you can perform operations on two types which are not the same:
    JavaScript:
    0 + "a"

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

      note that python also has some operations on different types (e.g 5 * "a" == "aaaaa")

  • @BryanAnderson-o1u
    @BryanAnderson-o1u ปีที่แล้ว

    wow i did not know templates existed until now lol i think i need to watch more videos on c++

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

    That's kinda interesting. I like the way rust handles generics way more tho. also surprised me that c++ just straight up implicity casts floats to ints lol, that's probably caused some headaches

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

      I'm a beginner but i'm pretty sure compilers will give you a warning if you're making any "unsafe conversions"

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

    0:03 complex langauge ☠️

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

      spelling error in the first 10 seconds 💀
      God that sucks :(

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

      @@cazz oh well, shit happens. that' quite clamplicated

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

    Variable templates, class templates, function templates

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

    Please make a mastering C++ playlist for us.

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

    Yo could you make a dll injection vid please 🙏

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

    Your new style of videos and your way of explaining programming are really outstanding and easy to understand! Keep on the good work!

  • @Cinarbayramic
    @Cinarbayramic 27 วันที่ผ่านมา +1

    I know what type to use because i make the functions

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

    keep it up bro!

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

    Good video

  • @sacredgeometry
    @sacredgeometry 23 วันที่ผ่านมา

    Python doesnt have weak typing it is strongly, dynamically typed. If you wanted a weak dynamic language you could have used javascript.

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

    New video let’s gooooooo

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

    So it's like the auto keyword but with functions?

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

    Explain const, constexpr, and other types of const

  • @Sl33pySt3rdust
    @Sl33pySt3rdust 8 หลายเดือนก่อน

    whats the difference between "template" and "template"?

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

      No difference

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

    where should we learn C++

  • @tahaanass3097
    @tahaanass3097 2 หลายเดือนก่อน

    how can i make a class template definition in a file and the implementation in another , somone can explain ?

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

    Next video:
    *How to extract the AIMBOT memory value of a battle royal game in Cheat Engine* ....
    Please please please its my humble request.😔

  • @-uz
    @-uz ปีที่แล้ว

    please continue these videos😘😍😍😍

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

    amazing video man

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

    Haha! And this is difficult? I mean the syntax seems far more coherent and easy to follow than Java's generics

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

    Fastest like this week 👍

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

    Cazz, can you make tutorials to hack the game Rust?

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

    cazz, how you learned c++

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

    Perfect video.

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

      thanks

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

    Can i hack games with lua ?

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

    👏👏

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

    he dont miss 🔥🔥🔥

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

    do mobile ios games please

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

    IIRC, SFINAE may be considered as an outdated technique now that "concepts/constraints" are available in C++20.

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

      I agree, it's just a matter of compiler support at the moment. MSVC has had full C++20 support for a while now at least. Also education, it's hard to find consumable videos about advanced C++ topics. It's gonna be a while before concepts and constraints become a part of the mainstream C++ world :crying:

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

      @@cazz Yes, and SFINAE is kinda hard to explain in an easy to digest video. Unless, the viewer knows a lot about C++ already.

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

      @@sledgex9 Absolutely. You require a certain amount of experience with the language before you can even begin to grasp why they exist / why you would ever need to use them 😆 it makes it difficult to make an 'easy' video about

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

    Rust == zero cost abstraction, just saying
    PS i use rust btw
    PPS great vid

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

      C++ is also supposed to have zero cost abstractions. That is one of the core principals behind the language. The problem is, you have to exhibit a really deep understanding of C++ for it to actually have zero cost abstractions. For example, classes in C++ are not literally zero-cost because of the hidden 'this' pointer, but if you understand that and you understand there is no other way of going about it (for C ABI compatability) then you realize that it's a necessary cost for the abstraction. The same goes for Virtual Methods and countless other "hidden" parts of C++.
      Thanks for comment and thanks for the compliment, have a great day!

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

    first because im cool

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

    third first

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

    first

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

      You were first. Can confirm 💯

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

      @@cazz is this sarcasm

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

      @@ikategame Nope. I'm dead serious.