From 4233117621331417408
X-Google-Thread: f78e5,52dd3e1082ac085e
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.speakeasy.net!news.speakeasy.net.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 05 Sep 2005 16:50:35 -0500
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Delivered-To: std-c++@ucar.edu
From: "Vladimir Marko" <swelef@post.sk>
Newsgroups: comp.std.c++
Subject: Re: unique_ptr
Organization: http://groups.google.com
Message-ID: <1125927788.249709.307810@g43g2000cwa.googlegroups.com>
References: <1125603471.570361.32720@o13g2000cwo.googlegroups.com>
   <hinnant-8804B5.11081102092005@syrcnyrdrs-03-ge0.nyroc.rr.com>
   <1125782448.174120.58820@g14g2000cwa.googlegroups.com>
   <hinnant-E0A574.13161304092005@syrcnyrdrs-01-ge0.nyroc.rr.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Complaints-To: groups-abuse@google.com
User-Agent: G2/0.2
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0,gzip(gfe),gzip(gfe)
Complaints-To: groups-abuse@google.com
Injection-Info: g43g2000cwa.googlegroups.com; posting-host=212.5.205.171;
   posting-account=0pNYQA0AAAA_FHDSc1l1QneuBRRhQETw
X-Greylisting: NO DELAY (Relay+Sender autoqualified);
	processed by UCSD_GL-v2.1 on mailbox4.ucsd.edu;
	Mon, 05 September 2005 06:44:18 -0700 (PDT)
X-Spamscanner: mailbox4.ucsd.edu  (v1.6 Aug  4 2005 15:27:38, -2.8/5.0 3.0.4)
X-MailScanner: PASSED (v1.2.8 58326 j85DiHPx059885 mailbox4.ucsd.edu)
X-Virus-Scanned: amavisd-new at ucar.edu
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Virus-Scanned: amavisd-new at cs.mu.OZ.AU
Date: Mon,  5 Sep 2005 16:42:29 CST
Lines: 50
NNTP-Posting-Host: 65.182.171.162
X-Trace: sv3-VeYtsS0hrv1hS/MBV9bqxQfcM3QUTlQV9oo3Wgb6U67c5XbfC0vDtzClbQ41hUwgLvN1n3E6UOq/KvF!kVf4p67ee/u3wScl4iQdKPwzt7x+VW8FF0eVVCM5jfpfat3jSbQ4X3xgFxEEveTgVrRbj/heBcEr!JPUVCNsh4dKdFFQd8ZVra5XZc6VgYuDok9Qjtcxh5rI=
X-Complaints-To: abuse@speakeasy.net
X-DMCA-Complaints-To: abuse@speakeasy.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.32
Xref: g2news1.google.com comp.std.c++:2022

Howard Hinnant wrote:
[...]
> 1.  What if the unique_ptr<T>(T* ...) constructors looked as you suggest:
>
> > explicit unique_ptr(T*&& p);
>
> AND, said constructors zero'd p?  I.e.:
>
> void foo(T* p)
> {
>     std::unique_ptr<T> up(std::move(p));
>     assert(p == 0);
> }
>
> This would actually put teeth into what it means to move from a built-in
> pointer type.  The ownership of the memory really is transferred away
> from the built-in pointer.

It would be great in debug mode. In release mode I would like the
compiler to optimize away the zeroing statement. ("You don't pay for
what you don't need.")

[...]
> 3.  This issue isn't specific to unique_ptr.  For any smart pointer for
> which the following would be bad:
>
> T* p = ...
> smart_pointer<T> p1(p);
> smart_pointer<T> p2(p);

Well, this is "almost good" for intrusive_ptr -- it should work, but it
provides a bad example for those who don't undestand what's going on
under the hood.

[...]
> Would we be willing to have all standard smart pointers behave in the
> same way with respect to how they accept raw pointers (be it rvalue
> only, zeroing, whatever)?

That would be good for new smart pointers. But for the old ones I'd go
for the backward compatibility.

Vladimir Marko

---
[ 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    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]



