Studying the standard, there was no information on how this would expand. I tried this in visual studio 2008 and it does a = a * (b + c); The standard guarantees that it will always expand to this, and not a = a * b + c? Has this expression always expanded for all standard C ++ versions?
Thank.
Yes, it is guaranteed.
a::operator*=(b + c);
EDIT:
Priority is not indicated in a good table in the standard, there is a note to 5/4saying:
5/4
The priority of the operators is not direct, but it can be obtained from the syntax.
The C ++ Reference table is correct.
=, *=, etc. () (. reference).
=, *=, etc.
, , , . ( , *=).
*=
a *= b + c "" , *= .
a *= b + c
, - .
*= . , a = a * (b + c), , , .
a = a * (b + c)
+ , *=, , b + c, a , *= - .
+
* = - . , , - , . .
, * = , , ", ", .
, , :
, , , "a = (a * b) + c", .
, , "" , , , -, ",",.
googling :
http://www.cppreference.com/wiki/language/operator_precedence
I donโt remember all the details, so itโs good to check if you are not sure between similar operators, but you can do most of this by remembering general principles like this.