• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

POP QUIZ #2: Find the bug in the following code.

Status
Not open for further replies.

maharg

idspispopd
Ah, I have it now, but I had to look it up because this kind of thing is lost in the deep recesses of my mind, so I think I lose points there.
It calculates the total number of combinations given two sets of v1 and v2 items respectively, correct?

Fafalada said:
Good idea about spoiler tagging, let's see if anyone else wants to have a go :)

Yup, this kind of stuff is basically an introduction to template metaprogramming. The things that can be done with it are quite fascinating, as a game programmer I can't help but be intrigued by any possibilities of improving compiler 'intelligence' so to speak.

I find it quite cool that game programmers seem to be getting right into the swing of things with some of the more modern C++ techniques. The business world is stuck reinventing wheels poorly over and over again, while I've heard of a couple of high profile game studios using the STL. (unspoiled at this point because I don't think this gives away the answer at this point :)

I hear, though, that the devkits this gen at least have come with rather poor C++ compilers. I got the impression that gcc2.95 seems to be the base of most of them. If that's what you're working with, wait until you get a compiler that can really handle metaprogramming :)
 

Fafalada

Fafracer forever
Yep, that's the correct answer.
I figure you've been out of school for awhile too, like me, so these things aren't so fresh in our minds anymore ;)

I find it quite cool that game programmers seem to be getting right into the swing of things with some of the more modern C++ techniques. The business world is stuck reinventing wheels poorly over and over again, while I've heard of a couple of high profile game studios using the STL.
Yeah, one of the reasons I switched from bussiness sector to games was wanting to work with and learn more modern approaches etc.
Speaking of which, when I started learning on the topic of metaprogramming more, I also came across Aspect oriented and Intentional programming, both of which seem to have been 'invented' more with bussiness apps in mind, but it doesn't seem like any of it managed to take off much, it stayed pretty obscure at best...

I hear, though, that the devkits this gen at least have come with rather poor C++ compilers. I got the impression that gcc2.95 seems to be the base of most of them. If that's what you're working with, wait until you get a compiler that can really handle metaprogramming
Well, the 3.x have been available for a bit less then a year now on PS2, but they did come pretty late in the game yes. And they are still far behind the actual GCC development curve :(
So yeah, there wasn't really a chance to start doing this stuf in production code (compiler switched mid-projects are also a big-no-no most of the time...).
 

rastex

Banned
Nice, that one was cool, thanks. I got it before reading the spoiler tags ;) it was just a matter of tracing through it until it clicked. I've known that you can do some funky stuff with code in compile time but never really saw it in action like this, very cool stuff indeed.
 

Loki

Count of Concision
This thread has been both entertaining and informative, despite my paltry single semester of C coding background about 5 years ago. :p :)
 

Jesiatha

Member
Fafalada said:
Well you're almost there - "what is F2" is the answer I am looking for.

v2 choose v1 (the number of way to choose v1 items from v2 items). I think there is probably some mathematical syntax for it, but I don't remember what it was.
 
Status
Not open for further replies.
Top Bottom