C++ Templates - Part 4 : Curiously Recurring Template Pattern

Поділитися
Вставка
  • Опубліковано 25 сер 2024

КОМЕНТАРІ • 36

  • @pmcgee003
    @pmcgee003 3 роки тому +10

    Goddamn this is the clearest explanation of crtp I've ever seen. 👍👍

  • @momusmomus
    @momusmomus 5 років тому +12

    Man. Someone is loving their cherry blues in the background

  • @burakcopur3841
    @burakcopur3841 6 років тому +9

    Man, your examples are really great.

  • @Jacklawi
    @Jacklawi 3 роки тому +3

    Wow I just finished watching your c++ series and it's just spectacular!! I wish you would do more videos like these...

  • @alek282
    @alek282 4 роки тому +1

    Your explanations are excellent! Please make more of these!

  • @NeustrDm
    @NeustrDm 4 роки тому +2

    Excellent as usual!

  • @tmmuttathara
    @tmmuttathara 6 років тому +7

    You can even create a paid course on Udemy. I won't mind buying one access.

  • @duality4y
    @duality4y 11 місяців тому

    these videos are a hidden gem.

  • @181Ravikiran
    @181Ravikiran 7 років тому +7

    Hello very nice Videos, Please make more videos, Thanks

  • @testshar2117
    @testshar2117 3 роки тому +1

    CRTP ----> Whenever a class/struct seems to use something which is templatized on itself.

  • @sebastianwilke626
    @sebastianwilke626 4 роки тому +1

    Hello Sir, I really like your way of explaining these advanced C++ topics and would love to see you in my subscription box again! (:

  • @DarkKnightUNS2008
    @DarkKnightUNS2008 7 років тому +1

    Great series. Keep up your good work

  • @tmmuttathara
    @tmmuttathara 6 років тому +2

    Hello, very interesting and useful content. Please make a tutorial on multi-threading and parallel programming.

  • @essmunson
    @essmunson Рік тому

    thank you so much for making this so easy to follow

  •  3 роки тому +1

    Great videos man!

  • @tanelhelmik
    @tanelhelmik 6 років тому +2

    Great Video good work.

  • @bimmerboard
    @bimmerboard Рік тому

    Nicely done!

  • @igoryungkee1703
    @igoryungkee1703 6 років тому +2

    Please make more videos!! You`re a good Thanks.

  • @Poti221
    @Poti221 3 роки тому

    Really Cool Explanation.

  • @amrtcpp6203
    @amrtcpp6203 3 роки тому +2

    Can someone explain the memory deletion process her ? how should clean what have been created inside the template?

    • @Henry14arsenal2007
      @Henry14arsenal2007 2 роки тому +1

      The Clone() function returns a pointer to a new Shape, which you can call delete on later on. Its not responsibility of the class to deal with that.

  • @notebook2866
    @notebook2866 Рік тому

    but it is still virtual, what's point ? it only helps you write code like macro does

  • @TVStrikers
    @TVStrikers 6 років тому +2

    Nice video.
    Why is it not possible to Change the line to:
    virtual Shape* Clone() override { return new T(static_cast(*this); }
    ?

    • @kylebelle246
      @kylebelle246 5 років тому +1

      im guessing the compiler wouldn't want to cast the actual data because there is a difference in size but will totally allow the cast to be done with pointers since well... they're just pointers. Thats the best i could come up with.

    • @wearecomingback5707
      @wearecomingback5707 5 років тому +1

      *this is ShapeCRTP
      T is Square
      So you cannot cast from a templated object to a non templated object.
      But
      “this” is a pointer
      You can always cast from a pointer to a pointer, the difference rises when you dereference the pointer.

  • @khatdubell
    @khatdubell 5 років тому

    _Says is going to make an abstract base class, proceeds to not make an abstract base class and then instantiates it_
    If you had actually made an abstract base class, the code wouldn't have compiled.

  • @vladimirchudyk995
    @vladimirchudyk995 3 роки тому +1

    This usage of CRTP is not correct. First it creates unnecessary bloat code. Second this is being taught with an idea behind polymorphism which is very wrong if CRTP is used this way since polymorphism was just created for the purpose it has. Consider looking at CRTP as a mixin but compilated and provided through a particular interface.

  • @yc4749
    @yc4749 4 роки тому

    What's the point of using CRTP if you are gonna make virtual function calls?

    • @unusualfashion
      @unusualfashion  4 роки тому +1

      I went with the polymorphic copy construction example from Wikipedia, as I felt that for people new to programming that it would be the easiest to understand and the most immediately relatable. It's still useful in this way for removing code repetition. I do however appreciate the fact that you were expecting to see the static polymorphism use case, and you're not the first person to mention it.

    • @yc4749
      @yc4749 4 роки тому

      oneproduct appreciated your reply and explanation. Thanks for your sharing. Hope to see more videos on C++ from you in the future.

  • @sonulohani
    @sonulohani 6 років тому +1

    Why does he have such a low subscriber count

  • @ashrasmun1
    @ashrasmun1 5 років тому +2

    The main advantage of using CRTP is the LACK of virtualisation. What you've shown is a special case in which the virtualisation is beneficial, but this is not the main point of the CRTP. I have to thumb it down for being somewhat misleading. People are trying to learn programming from you, and I am sure you have good will, but if you want to cover such broad topic, don't make a short video about it. It's like explaining to someone how to use a car by pouring fuel to the tank - you show a useful part of maintaining the car, but where's the driving part?

  • @ZER02641988
    @ZER02641988 6 років тому +5

    this is simply mess