

Nested Templates
Friday February 20, 2009
We have two IDEs at work: the awesome Visual Studio .NET, and the extremely incompetent "why the hell would anyone use this, oh, wait, we are because it compiles our PlayStation and Wii code" CodeWarrior. CW is a world of pain of its own, and here's a handy little tip for you.
Templates in C++ have the angle brackets as delimiters. That is, std::vector<int> or std::pair<int, int>. In Java and C#, they are refered to as generics, but for the sake of this post, they are essentially the same concept. (Check out the differences here).
Anyway, say I require a map of ints to a vector of ints. I would declare it as so:
std::map<int, std::vector<int>> mapping;
Looks okay? Wrong. Look again:
std::map<int, std::vector<int>> mapping;
That's the bitwise shift right operator. Of course, the fix is easy:
std::map< int, std::vector<int> > mapping;
Thanks Codewarrior.

That's a fail compiler. Or, rather, a fail lexer. ... not that I had to write something like that last week... not at all. -.-