mardi 16 août 2016

casting to the same type

I have this case:

using T = int; //T could be int and could be `short` in other platforms.
T a = 5;
auto x = static_cast<int>(a);

In case that T is long int the casting is must. In case of T is int the casting is redundant.

By standard, would the second casting be dropped since it is not necessary?

Aucun commentaire:

Enregistrer un commentaire