This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
a template question
- From: Nusret BALCI <balcinus at yahoo dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 23 Jul 2005 00:22:17 -0700 (PDT)
- Subject: a template question
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