Type Deduction and Explicit Type Specification
You will learn about type deduction and explicit type specification in this lesson.
We'll cover the following...
Type deduction
The compiler’s decision on what type to use for a template parameter is called type deduction.
Continuing from the example in the previous lesson, you may recognize that in syntax from to!string
, which we have been using in earlier, the compiler decides on the following types according to the two uses of the function template:
int
andwchar
when 42 is printeddouble
andstring
when 1.2 is printed
The compiler can only deduce ...