Type Traits

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

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

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

    The explanantion of 'why' Type Traits, at the beginning really helped me understand this, Thanks!

  • @ParveenSharma-ee9gl
    @ParveenSharma-ee9gl 2 ปีที่แล้ว +2

    I am glad that your channel focuses on these type of topics which are very essential building blocks and most of the time people think it's implicit that others know about it but are often not fully understood. Hoping for similar content in future as well.

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

      Nice observation. You mentioned the "building blocks" which we think of as the "basics". It can be difficult to understand the complicated ideas of C++ if your knowledge of the basics is missing. Other developers might be surprised at how much time we spend reviewing the basics in our own work.

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

    Perhaps the best programming content on the internet, and even within the c++ internet content. Thank you!

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

      Your comment is very inspiring. It can be a lot of work to prepare these videos and it is wonderful to know people find them worthwhile. Thank you!

  • @doge-coin
    @doge-coin 6 ปีที่แล้ว +2

    Your tutorial helps me a lot. Thank you so much!

  • @GurpreetKakar4873
    @GurpreetKakar4873 6 ปีที่แล้ว

    Extremely well explained.

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

    can you give me some example to practice with it?

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

      Could you give us a bit more information? If you are looking for real code which makes use of a type trait, take a look at our CsString library. In the file cs_string.h you will see several places where we use is_same, is_convertible, is_base_of, and is_array.

    • @tiennguyenviet4837
      @tiennguyenviet4837 6 ปีที่แล้ว

      thankyou so much! but i found some interested example in cplusplus.com.

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

    Thanks!!

  • @gaelecorchard3208
    @gaelecorchard3208 4 ปีที่แล้ว

    Very nice video, as the other ones of yours!
    I have a unrelated question. In Example B (5:40), what is the purpose of the second "typename" keyword before the return type of `doSomething`? Thanks.

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

      This is a wonderful question and the keyword typename is required in some odd places.
      In a "dependent type" template context such as T::X, the compiler clearly knows T is a data type. However, during parsing the compiler does not know if X is a data type, method, or even a data member. By adding the typename we are telling the compiler, I promise that during template instantiation X will be a data type.
      In our example X is the "::type" which depends on the template parameter T.

    • @_jmgomez_
      @_jmgomez_ 4 ปีที่แล้ว

      @@CopperSpice Interesting. Where the term "dependet type" comes from? Does it have something to do with actual dependent types? (en.wikipedia.org/wiki/Dependent_type) or is it just like the "functor" thing where it does not have anything to do with a real functor.
      Thanks!

    • @CopperSpice
      @CopperSpice  4 ปีที่แล้ว

      @@_jmgomez_ The term "dependent type" in C++ means something like T::name where the meaning depends on what T is. The compiler cannot determine whether "name" is a data type or a variable without knowing the value of T.
      The word functor actually does not have a meaning in C++, so it should never be used in reference to any C++ construct. Please check out our lambda expression video for more information about the terminology: th-cam.com/video/UOu_1Foq4mk/w-d-xo.html

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

    This was helpful! But i was surprised, that std::iterator_traits was not mentioned... i guess this is also a "Type Trait" construct?

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

      There are indeed a lot of type traits and we are glad you found the video of value. If you look around 3:40 char_traits and iterator_traits are on the 4th bullet point.

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

    nice