Consider this code:
template <typename T1, typename T2>
auto max(T1 t1, T2 t2) -> decltype(true?t1:t2)
{
return t2 < t1 ? t1 : t2;
}
When calling this function with ::max(5, 7.2)
I'm expecting the returned type to be int
as decltype(t1)
is in this case int
.
Why is the deduced return type double
in the above code when using operator?:
inside the decltype?
If I do -> decltype(t1)
I get the expected return type int
.
Aucun commentaire:
Enregistrer un commentaire