Template Type Deduction - Learn Modern C++

preview_player
Показать описание
The magic of templates allows us to call function templates without the hassle of specifying types explicitly. Let me show you what's going on inside.
Рекомендации по теме
Комментарии
Автор

You can use template class deduction to disable it.
Let's say we have a template vector class that looks like this:
template<class T = float>
class vec3{...};
Let's say we want to be able to declare the vector like this: vec3(1, 2, 3) - this will be vec3<int>(1, 2, 3) where we want it float, unless specified otherwise. You can use type deduction to disable type deduction.
template<T>
vec3(T x, T y T z) -> vec3<>

RedstoncraftAnim
Автор

Very good tutorial, tho I like it much more when you record your screen while coding and showing live examples, tho I guess it's fine in this case since there wasn't much code to be shown.

RedstoncraftAnim
welcome to shbcf.ru