Daily Archives: May 1, 2007

C++ parser bug

Ever had problems using templates in C++? Did you suddenly start to get problems when you started to use compound templates? Like a map of strings to vectors of strings for example. If so it was probably an odd bug in the parser (I really ought to find details of it in a book somewhere).

To prove the point try the following code,

map<string, vector<string>> var;

versus

map<string, vector<string> > var;

The first line will cause lots of errors, the second won’t. The C++ parser just doesn’t like the >>’s. It needs there to be a space. I guess it must be the lexxer interpretting the >>’s as the >> operator. Either way I’m guessing that has been the biggest obstacle to the STL’s adoption.

Follow

Get every new post delivered to your Inbox.

Join 58 other followers