From 964767553222300797
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,a0fcd8899dc05427
X-Google-Attributes: gidf78e5,public
From: JdeBP@jba.co.uk (Jonathan de Boyne Pollard)
Subject: Re: Implicit smart-to-dumb pointer conversions
Date: 1996/06/12
Message-ID: <4pm8e7$55m@silver.jba.co.uk>#1/1
X-Deja-AN: 159812354
references: <009A31CF34AEC020.4980D61E@ittpub.nl> <4ottpt$4i4@kelly.teleport.com> <4pihj9$bd8@news2.delphi.com> <gregorDsv7Dv.5tL@netcom.com>
x-original-date: 12 Jun 1996 12:07:51 +0100
organization: JBA Software Products, Studley, England.
x-auth: PGPMoose V1.1 PGP comp.std.c++
reply-to: JdeBP@donor2.demon.co.uk
newsgroups: comp.std.c++
originator: austern@isolde.mti.sgi.com


Greg Colvin (gregor@netcom.com) wrote:
| It is not hard to write a conforming auto_ptr that throws an exception when
| you dereference a dangling pointer, though there is some performance cost.
| A simple version just implements a reference counted pointer and puts an
| auto_ptr interface on it.  You could use such a version for debugging and
| switch to a more efficient version for production code.

Except that you are not allowed to do that.  auto_ptr is in namespace std,
and programs are not allowed to declare names in that namespace
[lib.reserved.names].  So you are stuck with whatever auto_ptr
is provided to you by the implementation.  

Yes, with conditional compilation, and judicious use of typedefs, you could
get around this.  

	#if defined(USE_DEBUGGING_AUTO_PTR)
	typedef throw_exception_auto_ptr my_auto_ptr ;
	#else
	typedef std::auto_ptr my_auto_ptr ;
	#endif

However, the disadvantage of this is that your code is now less
legible and thus less maintainable by other people, since it now does not
reference the "standard" auto_ptr class.

If you ask me, I think that auto_ptr is not ready for standardisation.  Let
the multiple different variants on auto_ptr be provided by third-party
libraries, and wait a few years to see what particular variant becomes
popular.  Then standardise that one.
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]



