
Why I Hate C++ Cast Operators (2003) - pmelendez
http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=285
======
makecheck
My reason for liking C++ casts is covered at the end, which is to say that
they're easier to find when scanning a code base. The article still tries to
debunk this using two defenses that I don't agree with.

First, compilers with sufficient warnings enabled _will_ tell you about
implicit conversions. Perhaps they didn't do as well in 2003 when the article
was written but they do now.

Second, you don't _really_ have to search for all 3 cast tokens individually
(most people would probably look for "_cast" and expect it to catch
everything). If you want to be explicit though, "egrep
'(dynamic|static|reinterpret)_cast'" isn't that hard, especially if you make
it a script.

I do agree that the definitions of static_cast<> and reinterpret_cast<> are a
bit unclear and to this day I probably screw them up in a few places. The
naming of const_cast<> is also weird since it removes both "const" and
"volatile", and it's even murkier now that C++11 has things like
std::remove_const (presumably the latter is to help template implementations
but are these not also forms of casting?).

Perhaps the operators should have been static methods in a standard class such
as "std::cast::..." so that all present and future cast-like conversions could
be found by searching for that prefix.

