04-13-2004, 12:57 PM | #1 (permalink) |
Location: Waterloo, Ontario
|
[C++] Why do I need the typename keyword?
I'm trying to port code from VC.net to VC.net 2003. Here's a typical piece of code that's often used:
Code:
template<class T> class PseudoContainer {
	typedef T::iterator iterator; // this line will change in the next example...
}; Code:
template<class T> class PseudoContainer {
	typedef typename T::iterator iterator; // this line was changed from the previous example...
}; Any insight into this will be greatly appreciated! |
04-13-2004, 03:06 PM | #2 (permalink) |
Wehret Den Anfängen!
Location: Ontario, Canada
|
VC6's template compiler is implemented almost like a macro. I can get some crazy shit to work that shouldn't under VC6... The parsing done by VC6 to a template is very minimal before it is instantiated. (I could be on crack, but this theory is consistent with the poking around I've done with templates)
When they did VC.net, they implemented a 'real' template compiler. Along the way, they ended up parsing more of the contents of a template. Which means they needed to know of a token was a type or a constant.
__________________
Last edited by JHVH : 10-29-4004 BC at 09:00 PM. Reason: Time for a rest. |
Tags |
keyword, typename |
|
|