Maximum Munch Discussion


First, I do not think that there is any discussion of "Maximum Munch" in the CTE documentation, nor your text, nor the reference book. So, here goes:

The "max munch" rule says that, when interpreting the characters of source code into tokens, the compiler makes the longest tokens possible. Therefore >> is always interpreted as a single token, the stream input operator, and never as two individual > tokens.

Later in the course you will see that

  template<class T = X<Q>> 

has to be written with an extra space:

  template<class T = X<Q> > 

to avoid this interpretation.

So, the next question is: what about +++++++++...? If the sequence has an even number of + characters, it will be interpreted as ++ ++ ++ ++ ... ++, a sequence of binary ++ tokens. If the sequence has an odd number of + characters? Then it will be interpreted as ++ ++ ++ ++ ... ++ +, a series of binary ++ tokens ending with a final unary +.