* Vincent RICHOMME:
Is there any reason to use static_cast instead of old C syntax ?
Let's say I declare
GLfloat test = static_cast<GLfloat>(x);
or
GLfloat test = (GLfloat) x;
once compiled is the code different ?
Wrong question. :-)
However, Victor already answered that.
Right question 1: what kinds of errors do static_cast help identify
(i.e. what code will not compile)?
Answer: all kinds of casts that are not static casts, namely reinterpret
casts, const casts and casting to inaccessible base.
Right question 2: what does static_cast communicate to the reader of the
code?
Answer: that you're intending to cast between related types, namely that
the types are assumed to be related in one of the ways supported by
static_cast, and also that you're competent enough to know the
difference (which is very important when maintaining code and making
decisions about what to investigate, i.e is that dubious construct most
probably intentional, a bug, or just arbitrary meaningless stuff?).
Right question 3: what other advantages are there?
Answer: for example, it's much easier to search for static_cast than to
search for a C style cast or a C++ "pseudo constructor call" cast.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?