News for hackers. Stuff that matters.
Re:Obscure C++ Features by jomar on Friday April 19, 2013 @02:32PM (#5578024)
If this were just

    if (mouse = dynamic_cast<MouseEvent *>(event))
then it would indeed just be an if condition expression that happened to be an assignment.

But the variable is being declared as well, so what's actually going on here is a declaration and an initialiser expression. There is actually new functionality here that needed a bit of language design thought, e.g., the declared variable's scope is the whole if statement, not just the condition expression.

Re:Obscure C++ Features by kelnos on Friday April 19, 2013 @03:01PM (#5578158)
I see this as no different than being able to do

    for (int i = 0; i < len; ++i) { }
Re:Obscure C++ Features by axusgrad on Friday April 19, 2013 @04:37PM (#5578589)
Imagine my surprise, getting out of college and trying to use this at my job, when the compiler told me it was invalid! It wasn't obscure to me, but apparently was to the Sun Studio C++ compiler.
Re:Obscure C++ Features by wiml on Friday April 19, 2013 @05:18PM (#5578752)
It was added in C99, I think.
Re:Obscure C++ Features by shrughes on Friday April 19, 2013 @05:46PM (#5578856)
It was added in C++ before that.