C++ is really incredibly hard to parse -- much more difficult than most other languages. It is a very consistent language, but so much work is done between tokenizing the input and understanding the grammatical analysis of the syntax, that things that seem like they should be simple for a compiler, often are NOT.
The historical ">>
" operator is an operator. It is "identified" as the source file is broken into tokens. Those tokens are then later "understood" in some context during grammatical analysis (long after tokenization is complete).
If you did grammatical analysis while you tokenized, then you have "helps" to assist in the distinction that ">>
" should be considered as two closures to a template declaration (or definition). Yet, this is historically not how historical C++ compilers work. (New compilers do more feedback between grammatical analysis and tokenization, including more "look-aheads" to help resolve these ambiguities.)
Yes, the new C++0x standard changes that, and forces compiler vendors to re-write their implementations to disambiguate ">>
" in your case. So, it will never be ambiguous going forward. However, older C++ compilers cannot handle that, so it may be considered "good practice" to keep your code compatible with the space between the '>
' characters for now.
vector < pair < int, int >> s;
could be(vector < pair < int),(int >> s);
– Tuberose