With both g++ and clang it's ok to compile
std::vector<int> xs{1, 2, 3u};
but it's not ok to compile
std::vector<int> xs{1, 2, 3.0};
What is the rationale behind this apparently bizarre choice?
If we consider the type of the last value both unsigned
and double
cannot be converted safely to an int
, and if we consider instead the specific literal values both 3u
and 3.0
can instead be converted safely.
Why the distinction then?
Aucun commentaire:
Enregistrer un commentaire