What do you think is the best?
template <typename T> void func(T x,T y) {}
or
template <typename T> void func(T x,decltype(x) y) {}
IMHO, the second form seems preferable because the relationship between types x and y is explicit and, at least when renaming the template identifier, things seem less error prone.
EDIT
The second form allows you to call a function with a subtype of one use for the first parameter, while the first form requires the same types. This argument seems a little better than the previous one.
source
share