By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,495 Members | 1,321 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,495 IT Pros & Developers. It's quick & easy.

Template syntax...

P: n/a
Hi!

I'm trying to compile the code above code (actually a similar one...),
and I get this error (with gcc 3.2.2) :

trick_1.cpp:16: template parameters not used in partial
specialization:
trick_1.cpp:16: `P_args'

Does anybody spot the error ? I know probably this code is invalid,
but I cannot see the right syntax... could also someone point me any
pointer on the web to learn template syntax in a quite deep manner ? I
encountered quite frequently blocking points like that for me...
Thanks anybody !

Bye!

Pyper.

/*** begin code ***/

template <class P_args> struct Thing {

struct SubThing {

template <unsigned int x> struct Func {

enum { value = 0 };

};

};

};

template <class P_args> struct Thing<P_args>::SubThing::Func<1> {

enum { value = 2 };

};

int main(int argc,char **argv) {

}

/*** end code ***/
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Davide Pippa wrote:
I'm trying to compile the code above code (actually a similar one...),
and I get this error (with gcc 3.2.2) :

trick_1.cpp:16: template parameters not used in partial
specialization:
trick_1.cpp:16: `P_args'

Does anybody spot the error ?
See below.
I know probably this code is invalid,
but I cannot see the right syntax... could also someone point me any
pointer on the web to learn template syntax in a quite deep manner ?
Sorry, I use books.
I
encountered quite frequently blocking points like that for me...
Perhaps you should put more effort into systematic learning of templates.
Get yourself a copy of "C++ Templates" by Vandevoorde and Josuttis.
Thanks anybody !

Bye!

Pyper.

/*** begin code ***/

template <class P_args> struct Thing {

struct SubThing {

template <unsigned int x> struct Func {

enum { value = 0 };

};

};

};

template <class P_args> struct Thing<P_args>::SubThing::Func<1> {
I believe the syntax should be

template<class P> template<> struct Thing<P>::SubThing::Func<1U> {

enum { value = 2 };

};

int main(int argc,char **argv) {

}

/*** end code ***/


V
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.