Originally Posted by
MutantJohn
Also, I didn't know that, is it really that easy to cast away constness using that? I always thought you had to do more nefarious things to effectively undermine const-ness
Const casting is actually one of the first things C++ tries to do to resolve (type)foo, it then tries static_cast, then a combination of static_cast and const cast to get to type. If all of those fail, then reinterpret_cast is used - the most permissive cast. The danger in C casting is the tendency to devolve into reinterpret_cast from some other mistake or from being short sighted about design.
Take this code, which only reinterpret_cast would compile.
Code:
int *v = something;
double d = double(v);
Forgetting the * is disastrous here.
C casting can be shorthand for something that you're sure will succeed before reinterpret_cast is used, so I don't necessarily blame you, but yeah it can remove const.