Is `+++` its just a fix step, followed by an infix (always)?

Consider the SO question hosted for Java. How does the +++ operator work?

Ok i understand that

  • There is no operator like "+++", its just a incremental increment followed by the add infix
  • This is a crime against readability.

What I want to know (just for the sake of curiosity) IF

+++ its just a incremental increment followed by infix, add , and not +++ its just an incremental infix followed by a prefix increment or its undefined behavior .

Note that I tested the following program

 #include <iostream> int main() { int x = 1; std::cout<< x+++1 << std::endl; std::cout<< 1+++x << std::endl; } 

in VC ++, gcc and g ++, and they all correspond to what

 '+++' its just a post-fix increment followed by an infix add 

but not

 '+++' its just an infix add followed by a prefix increment 
+3
source share
1 answer

Yes, the maxunch munch rule tells us that +++ parsed as ++ + (not a postfix followed by an infix, but a postfix followed by a + operator), which also displays

 1+++x <----> 1++ + x 

illegal because 1 not an lvalue.

+15
source

All Articles