a template question

Nusret BALCI balcinus@yahoo.com
Sat Jul 23 07:22:00 GMT 2005


Hello all,
I'm trying to compile the following code:
///////////////////////////////////////////
template <typename data_type, int stack_size>
class Array
{
	public:
static data_type* get_array(int length)
{
	if(!_Environment_<stack_size>::vstack)
		return
_Environment_<stack_size>::stack->get_array<data_type>(length);
	else
		return
_Environment_<stack_size>::vstack->get_array<data_type>(length);
}
};
////////////////////////////////////////////////
Here _Environment_ is another template class.

The code compiles and works correctly under
MSVC.NET2003. But not under MinGW 3.4.4. 

The same code compiles without any problem if I remove
the wrapper class and define the function as a
standalone template function. Error is about the line

_Environment_<stack_size>::vstack->get_array<data_type>(length);

Error: Primary expression expected before >

However, this error doesn't show up in case of
template function, instead of a template class.

As I need to keep my code compilable under linux, as
well as under Windows, I would appreciate if someone
can tell me whether this behavior is the current state
of the art in GCC world (for compiler version 4.01 for
instance), or it's a past thing which affects 3.4.*
series. Unfortunately I have no access to a linux
machine, therefore I'm stuck with MinGW, and they
don't have the 4.01 series yet, even if it solves this
issue. Does it?

Or, what's wrong with this code, and why the same
thing works for template classes, but not for template
functions..

Best regards,

Nusret


		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 



More information about the Gcc-help mailing list