Topic: Why has vector<vector<int>> been *kept* illegal?


Author: pjp@dinkumware.com ("P.J. Plauger")
Date: Mon, 16 May 2005 16:21:02 GMT
Raw View
"Samee Zahur" <samee.zahur@gmail.com> wrote in message
news:1115893090.218376.204870@g49g2000cwa.googlegroups.com...

> We know that > can be a 'greater-than' operator, or it can be an
> ending-delimiter for template parameters.
>
> So why has the >> operator not been defined as being capable of ending
> two template paramenter lists in a row? That would make things like
> vector<vector<int>> legal without any extra space!
>
> I know it is sometimes good coding practice to keep the space, but
> shouldn't coding style be there for the programmer to decide? What is
> the rationale behind this language design?

The rationale stems from a basic principle of C++ (and C) parsing
known as the "maximum munch" rule. It says that the longest
sequence of characters that can make a valid token is always
the next token. Thus ">>" always wins out over ">" ">".

Having said that, I must report that the C++ committee seems to
have solved this annoying problem last month in Lillehammer. The
next revision of C++ will indeed accept "vector<vector<int>>"
with the meaning we all want.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]