For nested templates, when did `>>` become standard C++ (instead of `> >`)?

Templates closed with nested >> are officially supported by the upcoming standard C++0x (now C++11). Previously you would need the space, or a compiler that went the extra mile for you (and did things not indicated by the standard).

The issue stems from the fact that >> in C is the right-shift operator, which is a single lexical token, which conflicts with the two separate > tokens that would be needed during the parsing stage in a classically-constructed C++ compiler (and only in the case of templates, not when it actually is a right-shift). In other words, the >>, if allowed to close nested templates, is lexically ambiguous, but this can be (and is being) addressed by extra sophistication during parsing (which in modern C++ is really nothing new).

Leave a Comment