Article View: comp.std.c++
Article #2288Defining Member Templates
From: Scott Meyers
Date: Mon, 23 Oct 1995 21:56
Date: Mon, 23 Oct 1995 21:56
34 lines
1504 bytes
1504 bytes
How can I define a member template outside the definition of the class?
For example, consider this declaration for auto_ptr (from the latest
DWP):
template<class X> class auto_ptr {
public:
template<class Y> auto_ptr(auto_ptr<Y>&);
...
};
}
If I want to implement this function inside the class template, that's
easy,
template<class X> class auto_ptr {
public:
template<class Y> auto_ptr(auto_ptr<Y>&) { /* impl goes here */ }
...
};
}
but what if I want to put it outside the class definition? Then what
do I say? The only thing I can think of is this:
template<class X>
template<class Y> auto_ptr(auto_ptr<Y>&) { /* impl goes here */ }
Is this the right way to do it?
Scott
[ 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:
<smeyersDGx8r7.BM3@netcom.com>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: smeyers@netcom.com (Scott Meyers) Newsgroups: comp.std.c++ Subject: Defining Member Templates Date: 23 Oct 1995 21:56:47 GMT Organization: NETCOM On-line Communication Services (408 261-4700 guest) Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <smeyersDGx8r7.BM3@netcom.com> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text Apparently-To: comp-std-c++@uunet.uu.net Content-Length: 745 X-Lines: 30 Originator: clamage@taumet