I am aware that the different casting operators in C++ have already been discussed here many times but my question is specifically about casting between numeric types, not about the general differences between C style and C++ style operators. I consider this a completely different topic than casting within a class hierarchy.
Say I want to cast an int i
to a double, some of the options I have are
static_cast<double>(i)
(double) i
double(i)
Personally I prefer the constructor-like style in the 3rd line in this case because I like to express that this is not a cast beteen class types, where I would certainly use static_cast
or dynamic_cast
.
Except from making it difficult to find this type of cast when searching in a text editor, are there any drawbacks of my choice?