What does the extension * = b + c mean?

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.

+3
source share
6 answers

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:

The priority of the operators is not direct, but it can be obtained from the syntax.

The C ++ Reference table is correct.

+16
source

=, *=, etc. () (. reference).

, , , . ( , *=).

+6

a *= b + c "" , *= .

+5

, - .

0

*= . , a = a * (b + c), , , .

+ , *=, , b + c, a , *= - .

0

* = - . , , - , . .

, * = , , ", ", .

, , :

  • a * = (b + c) ( , a = a * (b + c) sane)
  • As (a * = b) + c ( , , a b, a. c, )

, , , "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.

0
source

All Articles