Article View: comp.std.c++
Article #3402Template specialization with template?
From: nicolas (n.) chapados
Date: Thu, 22 Feb 1996 17:13
Date: Thu, 22 Feb 1996 17:13
37 lines
2057 bytes
2057 bytes
It sometimes would be useful to have a template specialization be
itself a template. For example, to define persistent I/O on all
vectors of type T, one could specialize PersistentIO<T>:
template <class T>
class PersistentIO< vector<T> >
{ ... };
I'd like to know whether this is allowed by the current draft.
Given the affirmative, what does the T argument represent inside
the specialization?
An alternative, which is not unfortunately not supported, would be
to define a specialization as a friend inside vector<T>:
template <class T>
class Vector<T> {
public:
// ...
friend class PersistentIO< vector<T> >
{ ... };
};
Could someone enlighten me as to why it is not permitted to define
a friend class inside another class, whereas defining a friend
inline function in a class is perfectly acceptable (and very useful
when used with templates)?
Nicolas Chapados
chapados@bnr.ca
---
[ To submit articles: Try just posting with your newsreader. If that fails,
use mailto:std-c++@ncar.ucar.edu
FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Technical Details
Message-ID:
<312BF6A1.5BBE@bnr.ca>Path:
arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austernShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!chronicle.mti.sgi.com!austern From: "nicolas (n.) chapados" <chapados@bnr.ca> Newsgroups: comp.std.c++ Subject: Template specialization with template? Date: 22 Feb 1996 09:13:53 PST Organization: Bell Northern Research Approved: austern@isolde.mti.sgi.com Message-ID: <312BF6A1.5BBE@bnr.ca> NNTP-Posting-Host: isolde.mti.sgi.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Original-Date: Wed, 21 Feb 1996 23:52:49 -0500 Content-Identifier: Template spec... X-Mailer: Mozilla 2.0 (Win95; I) X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBMSykXUy4NqrwXLNJAQEfegIAtmRgTf+AS0rS1Wj3HhbRO0k/JLo8EURE OPaYHx3kavfQdJ0N9bdPxNFG6OuGMywL0ladmVywBpemkHc691d5RQ== =sSL+ Originator: austern@isolde.mti.sgi.com