🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: sample auto_ptr template

#3992
From: Igor Boukanov
Date: Thu, 11 Apr 1996 16:47
30 lines
1906 bytes
Greg Colvin (gregor@netcom.com) wrote:
> This was a hard call, and I'm open to suggestions.  Adding a mutable
> member to a class is never pretty, but making the member visible in any
> way is ugly:  I don't like for a const argument to change its value,
> and I think of the value of an object as being whatever its public
> interface reveals. 

But why in this case instead of adding mutable member just change
auto_ptr<T>(const auto_ptr<T>&) to auto_ptr<T>(auto_ptr<T>&)
and 
auto_ptr<T>& operator=(const auto_ptr<T>&) to
auto_ptr<T>& operator=(auto_ptr<T>&)

This will explicitly reflect the semantic of auto_ptr and if somebody really 
want to change the state of const object, they can explicitly wright
about this:
auto_ptr<someType> autoPtr(const_cast<auto_ptr<someType>&>(autoPtrConst)); 


--
Regards, Igor Boukanov. 
igor.boukanov@fi.uib.no  
http://www.fi.uib.no/~boukanov/


[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  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: <4kjcvb$ghf@ugress.uib.no>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
References: <009A0A5CE1159CC0.49802F14@ittpub.nl> <gregorDpoGM2.Hw2@netcom.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: boukanov@sentef1.fi.uib.no (Igor Boukanov)
Newsgroups: comp.std.c++
Subject: Re: sample auto_ptr template
Date: 11 Apr 1996 16:47:47 GMT
Organization: Fysisk institutt, Universitetet i Bergen
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <4kjcvb$ghf@ugress.uib.no>
References: <009A0A5CE1159CC0.49802F14@ittpub.nl> <gregorDpoGM2.Hw2@netcom.com>
NNTP-Posting-Host: taumet.eng.sun.com
X-Nntp-Posting-Host: sentef1.fi.uib.no
X-Newsreader: TIN [version 1.2 PL2]
Content-Length: 886
X-Lines: 23
Originator: clamage@taumet