Yes..this is my name...

Jeremy's Blawg

Saturday, February 21, 2009

Nested Templates

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.

Posted by Jeremy at 11:45am :: 1 comment ::

Tags: templates, codewarrior, fail

Comments

Steve (23 Feb 09, 08:42)  
That's a fail compiler. Or, rather, a fail lexer.

... not that I had to write something like that last week... not at all. -.-

Make a comment

Name:
Message:
Confirmation:
It's....
    
:: Google Friend Connect ::

Mouseover to Expand:

:: Shoutbox ::
Refresh Shoutbox
:: Graffiti Wall ::

See my Graffiti Wall

Latest drawings by:

» mucus-free
» birthday candles
» gaga guwawa?
» goodyear
» birthday star
» Wishmaker
» best.name.ever
» Benjamin
» cawbirdie
:: Archive ::