-
Notifications
You must be signed in to change notification settings - Fork 266
Description
Something I haven't seen addressed or talked about is how cppfront
or the new cpp2 syntax will handle type casting. When I write code, I try to be very explicit and specific with my types and that includes adding a ton of casts. I also do thing such as turn on -pendaic
and -Werror
to catch any type casts that I might have missed to do.
Is there any proposal to make casting easier and simpler?
E.g., I've never understood why I might get a warning/error from a compiler if I do this:
int32_t a = 0;
int64_t b = a;
I can understand the cast from 64 -> 32 bits, since there is a loss in precision. But not from going 32 -> 64 bits since there is a growth in the precision.
Talking about the syntax for the moment, I've also had my share of colleagues who don't like writing out static_cast<>
because they thing "It's too long to type out when just a simple C-style cast suffices.". Is there a syntactical change that could be make to make proper casting easier?. E.g. reduce static_cast<>
to scast<>
?
I'm also not sure if the names of static_cast
, dynamic_cast
, reinterpret_cast
and const_cast
are that great, as when I first was learning C++ a decade+ ago I had trouble trying to understand the meaning of the assigned names.