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 

circumventing recursive definition wrt template specializati

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
SainTiss
Guest





PostPosted: Fri Nov 07, 2003 6:36 am    Post subject: circumventing recursive definition wrt template specializati Reply with quote



Hi,

If you've got a template class with lots of methods,
and then you've got a type which works with the template,
except for one method...

What you need to do there is specialize the template for your
type. However, this requires you to copy the whole template, and
change the method, which leads to code duplication...
If there's only 1 template parameter, one can specialize the method
instead of the whole class, but with more template parameters,
this is impossible, because partial specialization of a
method isn't allowed...

Therefore, it would be handy to be able to do this:
template<class A, class T> myClass<A,T*> : public myClass<A,T*>

However, the compiler will complain that you're having a
recursive definition, which is illegal...
Obviously, the compiler thinks that myClass<A,T*> is being
defined here, and therefore no other definition exists...
But in this case, myClass<A,T*> is a template specialization,
and therefore there IS another definition, namely the original
template...

So, is there a reason why this isn't possible, or is this just
something that doesn't happen too often, and therefore not worth
extending the standard?

Thanks,

Hans

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards 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.