Consider the following function template:
template <typename T1, typename T2>
void foo(T1 a, T2 b){// Do something.}
Now assume that I want T1
to be int
, but T2
to be deduced by the compiler depending on the type of b
. Something like foo<int,...>(1,b)
. Is it possible?
Thanks!
Yes!
foo<int>(1, b);
But in that example above there is no benefit. The difference is visible if your first argument would not already be deduced to int
:
foo<int>(3.2f, b);
// ^^^^ Implicit conversion