Thread View: comp.std.c++
3 messages
3 total messages
Started by Martin Hitz
Fri, 15 Sep 1995 22:21
Partial Template Specialization
Author: Martin Hitz
Date: Fri, 15 Sep 1995 22:21
Date: Fri, 15 Sep 1995 22:21
33 lines
1612 bytes
1612 bytes
A while ago, Steve Clamage kindly pointed out to me that partial
template specializations where allowed by the draft standard.
Thus for a template
template<class T, int n> class X { ... };
it should be possible to explicitly specify a variant for, say,
class X<class T, 1> { ... };
where T is still a "free" formal parameter.
Although I know that most compiler don't support this feature yet,
I'am curious about the syntax of such a partial specialization
(I don't think the above example is correct).
Is anybody able to figure that out of the standard document?
Regards,
Martin Hitz
Applied Computer Science & | Email: Martin.Hitz@univie.ac.at
Information Systems | URL: http://www.pri.univie.ac.at
University of Vienna | Phone: +43-1-40103-2795
Rathausstrasse 19/4 | Secretary: +43-1-40103-2792
A-1010 Vienna (Austria, Europe) | Fax: +43-1-4066712
---
[ 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. ]
Re: Partial Template Specialization
Author: Steve Clamage
Date: Fri, 15 Sep 1995 22:49
Date: Fri, 15 Sep 1995 22:49
33 lines
1516 bytes
1516 bytes
In article 95Sep15152129@physics2.Berkeley.EDU, Martin Hitz <hitz@ftp.univie.ac.at> writes:
>
>A while ago, Steve Clamage kindly pointed out to me that partial
>template specializations where allowed by the draft standard.
>
>Thus for a template
>
> template<class T, int n> class X { ... };
>
>it should be possible to explicitly specify a variant for, say,
>
> class X<class T, 1> { ... };
>
>where T is still a "free" formal parameter.
>Although I know that most compiler don't support this feature yet,
>I'am curious about the syntax of such a partial specialization
>(I don't think the above example is correct).
According to the way I read 14.6, class template specialization, [temp.class.spec]
you would write
template<class T> class X<T, 1> { ... }
---
Steve Clamage, stephen.clamage@eng.sun.com
---
[ 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. ]
Re: Partial Template Specialization
Author: Gene Linetsky
Date: Sat, 23 Sep 1995 16:09
Date: Sat, 23 Sep 1995 16:09
40 lines
1781 bytes
1781 bytes
Steve Clamage (clamage@Eng.Sun.COM) wrote:
: In article 95Sep15152129@physics2.Berkeley.EDU, Martin Hitz <hitz@ftp.univie.ac.at> writes:
: >
: >A while ago, Steve Clamage kindly pointed out to me that partial
: >template specializations where allowed by the draft standard.
: >
: >Thus for a template
: >
: > template<class T, int n> class X { ... };
: >
: >it should be possible to explicitly specify a variant for, say,
: >
: > class X<class T, 1> { ... };
: >
: >where T is still a "free" formal parameter.
: >Although I know that most compiler don't support this feature yet,
: >I'am curious about the syntax of such a partial specialization
: >(I don't think the above example is correct).
: According to the way I read 14.6, class template specialization, [temp.class.spec]
: you would write
: template<class T> class X<T, 1> { ... }
: ---
: Steve Clamage, stephen.clamage@eng.sun.com
One could use it to avoid new and delete in a container:
template <class T, int size> Array
{
...
T array[size];
...
}
---
[ 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. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads