🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Cleaning auto_ptr copy semantics.

#3264
From: Randal Parsons
Date: Tue, 06 Feb 1996 15:41
44 lines
2321 bytes
Eugene Lazutkin wrote:
 
> I didn't find standard equal-operators:
 
> template<class T>
> bool            operator== ( const auto_ptr<T>& l, const T* r )
>                         { return l.get()==r; }
 
> template<class T>
> bool            operator== ( const T* l, const auto_ptr<T>& r )
>                         { return l==r.get(); }
 
> template<class T>
> bool            operator== ( const auto_ptr<T>& l, const auto_ptr<T>& r )
>                         { return l.get()==r.get(); }
 
> template<class T>
> bool            operator!= ( const auto_ptr<T>& l, const T* r )
>                         { return l.get()!=r; }
 
> template<class T>
> bool            operator!= ( const T* l, const auto_ptr<T>& r )
>                         { return l!=r.get(); }
 
> template<class T>
> bool            operator!= ( const auto_ptr<T>& l, const auto_ptr<T>& r )
>                         { return l.get()!=r.get(); }
 
> It's pretty convinient.  It's good if you are going to create a STL
> container of auto_ptr's.  In this case you can use STL's algorithms.
> Otherwise each programmer should implement this functions manually.
 

I agree. I'd like to treat an auto_ptr similarly to a normal pointer. 
This means that operator== and operator!= need to be defined. I'd 
also like to be able to test if its null or not - using operator!() 
and operator int().

Randal Parsons.

[ 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://reality.sgi.com/employees/austern_mti/std-c++/policy.html
]
Technical Details
Message-ID: <3116BE3B.1B73@btal.com.au>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
References: <01BAF15D.08B8EEE0@dino.int.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: Randal Parsons <Randal.Parsons@btal.com.au>
Newsgroups: comp.std.c++
Subject: Re: Cleaning auto_ptr copy semantics.
Date: 6 Feb 1996 15:41:05 GMT
Organization: Bankers Trust Australia Limited.
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <3116BE3B.1B73@btal.com.au>
References: <01BAF15D.08B8EEE0@dino.int.com>
NNTP-Posting-Host: taumet.eng.sun.com
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Nntp-Posting-Host: aupozx666.btal.com.au
X-Mailer: Mozilla 2.0b6a (WinNT; I)
X-Lines: 39
Content-Length: 1390
Originator: clamage@taumet