🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2014

Re: Partial Template Specialization

#2014
From: Gene Linetsky
Date: Sat, 23 Sep 1995 16:09
40 lines
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. ]
Technical Details
Message-ID: <selfDFAJ8r.Aq9@netcom.com>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <MATT.95Sep15152129@physics2.Berkeley.EDU> <MATT.95Sep15154934@physics2.Berkeley.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 23 Sep 95 16:09:14 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
From: self@netcom.com (Gene Linetsky)
Subject: Re: Partial Template Specialization
Message-ID: <selfDFAJ8r.Aq9@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
X-Newsreader: TIN [version 1.2 PL1]
References: <MATT.95Sep15152129@physics2.Berkeley.EDU> <MATT.95Sep15154934@physics2.Berkeley.EDU>
X-Original-Date: Fri, 22 Sep 1995 05:00:27 GMT