220 12597 <1DB1B82D-0067-4D01-A054-9113B6D7B3ED@gmail.com> article
Path: news.gmane.org!not-for-mail
From: David Krauss <potswa@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Questions about N3949 - Scoped Resource - Generic
 RAII Wrapper for the Standard Library
Date: Sun, 31 Aug 2014 23:26:44 +0800
Lines: 85
Approved: news@gmane.org
Message-ID: <1DB1B82D-0067-4D01-A054-9113B6D7B3ED@gmail.com>
References: <038222e0-66c3-4837-b158-e911dffb3c55@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\))
Content-Type: multipart/alternative; boundary="Apple-Mail=_AC6BF572-F08A-453E-B867-FAB5391CBDE0"
X-Trace: ger.gmane.org 1409498823 6599 80.91.229.3 (31 Aug 2014 15:27:03 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 31 Aug 2014 15:27:03 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCW25A7E3QCRBO75RSQAKGQEHB4MQTI@isocpp.org Sun Aug 31 17:26:57 2014
Return-path: <std-proposals+bncBCW25A7E3QCRBO75RSQAKGQEHB4MQTI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yk0-f198.google.com ([209.85.160.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCW25A7E3QCRBO75RSQAKGQEHB4MQTI@isocpp.org>)
	id 1XO71p-0006r5-PK
	for gclcip-std-proposals@m.gmane.org; Sun, 31 Aug 2014 17:26:54 +0200
Original-Received: by mail-yk0-f198.google.com with SMTP id q200sf16139523ykb.9
        for <gclcip-std-proposals@m.gmane.org>; Sun, 31 Aug 2014 08:26:52 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:message-id:mime-version:subject:date
         :references:to:in-reply-to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type;
        bh=EDuoFXQiUPx+MF70JbJIX/Ldj/JQKNg+EvEdSEuwsA0=;
        b=PKhv7e2oYTohFxtD6H23/YAsPMmJaRlp3+MwHF9ynkIF0uTSg5++zkOjS3UjaaZdUa
         vLZILZ9nBDGSuJ1gM6/YUBa7rg2yBZwd6TrwrtRcPaNYrZwyg9mMICPZHexxjZEsaTGf
         5k78eVWv436adofyrKuIexaH9x0MXf/Kc4nQCzf++uFCBgYIdNYkdPeRbL6gJ7OPvxOj
         ZPPXTJucv15i6E1fIIyY6jziIwAXqp1H5WwueLv0k5bk8pbDoaqpTRnyNAiaka3i/6bJ
         aRI32CPO1DMmzdv+wlW1jSmQK/pXw0gk3/P4RP5vZvrY3PivZfzgWnZirh1F+ekyCMtq
         bw2Q==
X-Gm-Message-State: ALoCoQn/BXTtJMp+Ji9RftdqrUEoyj/s0j5Q1mfYpXKHa3JJK/61TvebRY6kWkBSXSAGTBEifbB+
X-Received: by 10.236.227.169 with SMTP id d39mr10699963yhq.45.1409498812567;
        Sun, 31 Aug 2014 08:26:52 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.143.76 with SMTP id sc12ls1419199igb.3.gmail; Sun, 31 Aug
 2014 08:26:51 -0700 (PDT)
X-Received: by 10.70.37.67 with SMTP id w3mr31795887pdj.107.1409498811769;
        Sun, 31 Aug 2014 08:26:51 -0700 (PDT)
Original-Received: from mail-pa0-x22c.google.com (mail-pa0-x22c.google.com [2607:f8b0:400e:c03::22c])
        by mx.google.com with ESMTPS id v1si9958547pdq.30.2014.08.31.08.26.51
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Sun, 31 Aug 2014 08:26:51 -0700 (PDT)
Received-SPF: pass (google.com: domain of potswa@gmail.com designates 2607:f8b0:400e:c03::22c as permitted sender) client-ip=2607:f8b0:400e:c03::22c;
Original-Received: by mail-pa0-f44.google.com with SMTP id rd3so10276235pab.31
        for <std-proposals@isocpp.org>; Sun, 31 Aug 2014 08:26:51 -0700 (PDT)
X-Received: by 10.66.124.136 with SMTP id mi8mr32106905pab.89.1409498811358;
        Sun, 31 Aug 2014 08:26:51 -0700 (PDT)
Original-Received: from [172.20.10.2] ([121.54.54.53])
        by mx.google.com with ESMTPSA id ad10sm19259262pad.4.2014.08.31.08.26.48
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Sun, 31 Aug 2014 08:26:50 -0700 (PDT)
In-Reply-To: <038222e0-66c3-4837-b158-e911dffb3c55@isocpp.org>
X-Mailer: Apple Mail (2.1878.6)
X-Original-Sender: potswa@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of potswa@gmail.com designates 2607:f8b0:400e:c03::22c as permitted
 sender) smtp.mail=potswa@gmail.com;       dkim=pass header.i=@gmail.com;
       dmarc=pass (p=NONE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:12597
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/12597>

--Apple-Mail=_AC6BF572-F08A-453E-B867-FAB5391CBDE0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-08-31, at 10:03 PM, Adi Shavit <adishavit@gmail.com> wrote:

> Am I missing something here or is this by design?
> What is the rational for this and how would one a succinct scoped_resourc=
e declaration?

The difference between type-erased shared_ptr and fully-static unique_ptr, =
and its cousin scoped_resource, is an indirect function call. This is neces=
sary because a shared_ptr can almost never expect to know the dynamic type =
of the object it retains, but most unique_ptr use cases statically know the=
 dynamic type.

The solution is to add your own indirect call into the deleter, such as by =
using a naked function pointer pointer type as the deleter, or by virtual o=
perator ().

For what it's worth, I'm not convinced that scoped_resource provides any us=
eful encapsulation. Simply writing a class with a destructor is more terse =
and more expository. Virtual destructors are among the most widely-known id=
ioms in existence, and simply "doing things the old-fashioned way" would li=
kely have avoided this deleter confusion entirely.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--Apple-Mail=_AC6BF572-F08A-453E-B867-FAB5391CBDE0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014&=
ndash;08&ndash;31, at 10:03 PM, Adi Shavit &lt;<a href=3D"mailto:adishavit@=
gmail.com">adishavit@gmail.com</a>&gt; wrote:</div><br class=3D"Apple-inter=
change-newline"><blockquote type=3D"cite"><div dir=3D"ltr"><div>Am I missin=
g something here or is this by design?</div><div>What is the rational for t=
his and how would one a succinct scoped_resource declaration?</div></div></=
blockquote><div><br></div><div>The difference between type-erased <font fac=
e=3D"Courier">shared_ptr</font> and fully-static <font face=3D"Courier">uni=
que_ptr</font>, and its cousin <font face=3D"Courier">scoped_resource</font=
>, is an indirect function call. This is necessary because a <font face=3D"=
Courier">shared_ptr</font> can almost never expect to know the dynamic type=
 of the object it retains, but most&nbsp;<font face=3D"Courier">unique_ptr<=
/font>&nbsp;use cases statically know the dynamic type.</div><div><br></div=
><div>The solution is to add your own indirect call into the deleter, such =
as by using a naked function pointer pointer type as the deleter, or by <fo=
nt face=3D"Courier">virtual operator ()</font>.</div><div><br></div><div>Fo=
r what it&rsquo;s worth, I&rsquo;m not convinced that <font face=3D"Courier=
">scoped_resource</font> provides any useful encapsulation. Simply writing =
a class with a destructor is more terse and more expository. Virtual destru=
ctors are among the most widely-known idioms in existence, and simply &ldqu=
o;doing things the old-fashioned way&rdquo; would likely have avoided this =
deleter confusion entirely.</div><div><br></div></div></body></html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--Apple-Mail=_AC6BF572-F08A-453E-B867-FAB5391CBDE0--

.
