🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Defining Member Templates

#2291
From: John H. Spicer
Date: Tue, 24 Oct 1995 03:01
45 lines
1914 bytes
Scott Meyers wrote:
> 
> 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?
> 

Almost.

template <class X> 
	template <class Y> auto_ptr<X>::auto_ptr(auto_ptr<Y>&) { }

-- 
John Spicer
Edison Design Group
jhs@edg.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. ]
Technical Details
Message-ID: <308C41FE.7B7E1927@edg.com>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <smeyersDGx8r7.BM3@netcom.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
Date: 24 Oct 95 03:01:29 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
From: "John H. Spicer" <jhs@edg.com>
Subject: Re: Defining Member Templates
Content-Type: text/plain; charset=us-ascii
Message-ID: <308C41FE.7B7E1927@edg.com>
Sender: news@edg.com
Content-Transfer-Encoding: 7bit
Organization: Edison Design Group Inc.
References: <smeyersDGx8r7.BM3@netcom.com>
Mime-Version: 1.0
X-Original-Date: Tue, 24 Oct 1995 01:31:42 GMT
X-Mailer: Mozilla 2.0b1J (X11; I; SunOS 4.1.3_U1 sun4m)
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMIxXFuEDnX0m9pzZAQGhVAF+MjiTMMnX0osX4zRNh0g6jCNg1jhbj5uK
 qK90/QltLviwY4O4IuTQh2DgaPOGdg6E
 =bDfw