Article View: comp.std.c++
Article #2583Re: inheritance and templates
From: Sean A Corfield
Date: Thu, 16 Nov 1995 16:10
Date: Thu, 16 Nov 1995 16:10
45 lines
2143 bytes
2143 bytes
In article <48cekf$6ns@unidoct.Chemietechnik.Uni-Dortmund.DE>,
Thomas Arend <arend@Chemietechnik.Uni-Dortmund.DE> wrote:
|> I have some problems with the instatiation of templates,
|> especially partial instatiation, under g++ 2.7.0.
As Jason Merrill said, no compilers currently support partial
specialisation.
|> For some special values of T_size I need a special
|> behaviour, so I would like to overload 'x'. In this context
|> the datatype 'T' is not of interest.
I think you want something like this:
template<typename T> class A<T,N> { };
Where 'N' is your 'special value' of T_size. This partial specialisation
would then be used whenever an instantiation is required for T_size == N
with whatever type is specified for T.
Some more examples of the syntax:
template<typename T, typename U> class X { }; // primary template
template<typename T> class X<T,T> { };
// partial specialisation for when both args are the same
template<typename T, typename U, typename V, typename W>
class X<T U::*, V W::*> { };
// partial specialisation for two pointers to members
template<typename T, typename U> class X<T*,U*> { };
// partial specialisation for two pointer types
BTW, Thomas, your return email address does not work -- I tried to contact
you by email about this!
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<ACD0C16F9668A9A66@corf.demon.co.uk>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageReferences:
<48cekf$6ns@unidoct.Chemietechnik.Uni-Dortmund.DE>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: Sean A Corfield <sean@corf.demon.co.uk> Newsgroups: comp.std.c++ Subject: Re: inheritance and templates Date: 16 Nov 1995 16:10:18 GMT Organization: OCS Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <ACD0C16F9668A9A66@corf.demon.co.uk> References: <48cekf$6ns@unidoct.Chemietechnik.Uni-Dortmund.DE> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Nntp-Posting-Host: corf.demon.co.uk X-Nntp-Posting-Host: corf.demon.co.uk Content-Length: 1311 X-Lines: 41 Originator: clamage@taumet