ToTo said:
Where can I find a real standard reference of the C++
operator precedence? I presented to my students plainly the
table presented in the book "The C++ Programmin Language"
from Mr. Stroustrup (with my annotations). I have only a
working draft of the C++ standard where I could not find any
such table... Or does it mean it is _not_ part of the
standard?
There's no explicit table, but operator precedence can be
determined from the grammar in paragraph A.4 [gram.expr].
There is no real operator precedence. Consider:
a = b ? c : d, e ; // precedence: ?:, =, ,
a ? b = c, d : e ; // precedence: =, ,, ?:
this has nothing to do with precedence or assocaitivity ;conditional
is in priority but it needs its operands calculated before being
called , and since it is ternary the pair '?',':' behave as matching
braces and calculate the second parameter as if it were written with
paranthesis:
a ? ( b = c , d ) : e ;
conditional is unique in being ternary.
In VC++`s documentation , platform specific stuff is enclosed between
'microsoft specific' & 'end microsoft' phrases and the table of
operators is not guarded in that way ; Although It may be a bug in the
compiler`s documentation , I guess that this matter is - either
explicitly or implicitly - well defined in the standard .
Furthermore, how can you write a program that claims for portability
unless operator precedence (read syntax) is standardized?
Could such a fundamental matter have been neglected by the standard?
Or maybe since all the compilers follow similar semantics(due to some
common compiler source code somehow) standard commitee has not felt
any need for clarification????
regards,
FM.