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.
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.
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.
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.
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.
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.
@@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!
@@_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: ruclips.net/video/UOu_1Foq4mk/видео.html
The explanantion of 'why' Type Traits, at the beginning really helped me understand this, Thanks!
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.
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.
Perhaps the best programming content on the internet, and even within the c++ internet content. Thank you!
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!
Your tutorial helps me a lot. Thank you so much!
can you give me some example to practice with it?
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.
thankyou so much! but i found some interested example in cplusplus.com.
Extremely well explained.
This was helpful! But i was surprised, that std::iterator_traits was not mentioned... i guess this is also a "Type Trait" construct?
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.
Thanks!!
nice
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.
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.
@@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!
@@_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: ruclips.net/video/UOu_1Foq4mk/видео.html