C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

template.cpp:9: error: too few template-parameter-lists

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
jonas.ritter@gmx.de
Guest





PostPosted: Tue Dec 13, 2005 6:33 pm    Post subject: template.cpp:9: error: too few template-parameter-lists Reply with quote



I tried to compile the following code with g++ 3.4 and 4.0 and got the
error:

#include <iostream>
template <class T> class X {
static X<T> * xp;
};

X<int> * X<int>:Madp = NULL;

int main() {
return 0;
}

with g++ 3.2 it works
was something changed in the compiler or in c++ standard?
do I need to write the code differently?

Thanks

Jonas


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Thomas Tutone
Guest





PostPosted: Tue Dec 13, 2005 11:02 pm    Post subject: Re: template.cpp:9: error: too few template-parameter-lists Reply with quote



[email]jonas.ritter (AT) gmx (DOT) de[/email] wrote:
Quote:
I tried to compile the following code with g++ 3.4 and 4.0 and got the
error:

#include <iostream
template static X<T> * xp;
};

X<int> * X<int>:Madp = NULL;

change the above line to template<> X<int> * X<int>:Madp = 0;
(I'm not sure whether including <iostream> necessarily results in
defining NULL.)

Quote:

int main() {
return 0;
}

with g++ 3.2 it works
was something changed in the compiler or in c++ standard?

The later versions of gcc are more conforming to the standard.

Quote:
do I need to write the code differently?

As shown above.

Best regards,

Tom


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Thomas Maeder
Guest





PostPosted: Wed Dec 14, 2005 6:11 am    Post subject: Re: template.cpp:9: error: too few template-parameter-lists Reply with quote



"jonas.ritter (AT) gmx (DOT) de" <jonas.ritter (AT) gmx (DOT) de> writes:

Quote:
I tried to compile the following code with g++ 3.4 and 4.0 and got the
error:

#include <iostream
template static X<T> * xp;
};

X<int> * X<int>:Madp = NULL;

Side note: NULL is not declared here.


Quote:
int main() {
return 0;
}

with g++ 3.2 it works
was something changed in the compiler or in c++ standard?

The compiler was made more conforming.


Quote:
do I need to write the code differently?

template <>
X<int> * X<int>:Madp = NULL;

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Gene Bushuyev
Guest





PostPosted: Wed Dec 14, 2005 6:13 am    Post subject: Re: template.cpp:9: error: too few template-parameter-lists Reply with quote

<jonas.ritter (AT) gmx (DOT) de> wrote

Quote:
I tried to compile the following code with g++ 3.4 and 4.0 and got the
error:

#include <iostream
template static X<T> * xp;
};

X<int> * X<int>:Madp = NULL;

int main() {
return 0;
}

with g++ 3.2 it works
was something changed in the compiler or in c++ standard?
do I need to write the code differently?



No, the standard didn't change, rather the compilers are getting better.
In your code, you missed the template<> to define the explicit specialization:

template<>
X<int>* X<int>:Madp = NULL;

-- Gene Bushuyev
----------------------------------------------------------------
There is no greatness where there is no simplicity, goodness and truth. ~ Leo
Tolstoy


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
kanze
Guest





PostPosted: Wed Dec 14, 2005 3:41 pm    Post subject: Re: template.cpp:9: error: too few template-parameter-lists Reply with quote

Thomas Tutone wrote:
Quote:
jonas.ritter (AT) gmx (DOT) de wrote:
I tried to compile the following code with g++ 3.4 and 4.0
and got the error:

#include <iostream
template static X<T> * xp;
};

X<int> * X<int>:Madp = NULL;

change the above line to template<> X<int> * X<int>:Madp = 0;
(I'm not sure whether including <iostream> necessarily results
in defining NULL.)

It's undefined. In the case of g++, <iostream> does define
NULL, so it's not his problem, but he should really add an
#include <stddef.h> or #include <cstddef>, just to be sure.

As other's have pointed out, his real problem is the absense of
a template<>. Without that, his code doesn't compile, neither
with NULL nor with 0.

--
James Kanze GABI Software
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Thomas Tutone
Guest





PostPosted: Wed Dec 14, 2005 9:00 pm    Post subject: Re: template.cpp:9: error: too few template-parameter-lists Reply with quote

kanze wrote:
Quote:
Thomas Tutone wrote:
[email]jonas.ritter (AT) gmx (DOT) de[/email] wrote:
I tried to compile the following code with g++ 3.4 and 4.0
and got the error:

#include <iostream
template static X<T> * xp;
};

X<int> * X<int>:Madp = NULL;

change the above line to template<> X<int> * X<int>:Madp = 0;
(I'm not sure whether including <iostream> necessarily results
in defining NULL.)

It's undefined. In the case of g++, <iostream> does define
NULL, so it's not his problem, but he should really add an
#include <stddef.h> or #include <cstddef>, just to be sure.

As other's have pointed out, his real problem is the absense of
a template<>. Without that, his code doesn't compile, neither
with NULL nor with 0.

I agree. Please look back at my suggested correction - it includes the
missing template<>. The parenthetical reference to the NULL problem
was just an aside.

Best regards,

Tom


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.