220 9493 <C06AD35E-4462-4868-834D-0F105538621D@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: Feedback on N3949 - Scoped Resource - Generic
 RAII Wrapper for the Standard Library
Date: Mon, 3 Mar 2014 02:08:14 +0800
Lines: 129
Approved: news@gmane.org
Message-ID: <C06AD35E-4462-4868-834D-0F105538621D@gmail.com>
References: <CAFk2RUbEtKVv59CzdT-qittbwk64Z=cKBFkP__Z8_kdoPSa5Vg@mail.gmail.com> <67F4693D-4473-4700-A60E-8C434D55E226@gmail.com> <CAFk2RUafGLPR+o1hFtBJjS7Ho0Ms1_q-Mtazsf5jp8CFF-5qqA@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\))
Content-Type: multipart/alternative; boundary="Apple-Mail=_81527C4F-4DFC-41C0-9493-29580E16A543"
X-Trace: ger.gmane.org 1393783700 32047 80.91.229.3 (2 Mar 2014 18:08:20 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 2 Mar 2014 18:08:20 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCW25A7E3QCRBGPHZWMAKGQE6NKZFMQ@isocpp.org Sun Mar 02 19:08:28 2014
Return-path: <std-proposals+bncBCW25A7E3QCRBGPHZWMAKGQE6NKZFMQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qc0-f198.google.com ([209.85.216.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCW25A7E3QCRBGPHZWMAKGQE6NKZFMQ@isocpp.org>)
	id 1WKAoO-0005ak-3H
	for gclcip-std-proposals@m.gmane.org; Sun, 02 Mar 2014 19:08:28 +0100
Original-Received: by mail-qc0-f198.google.com with SMTP id r5sf5112943qcx.5
        for <gclcip-std-proposals@m.gmane.org>; Sun, 02 Mar 2014 10:08:27 -0800 (PST)
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=lbexyaElf3wS6fJev/QURv/2SFj+kRrwniPqQbVs74o=;
        b=MRycfhYgZz8LwU/G9psHxoJdf6tePCq+SxGYGXm2JYiUft1c6JQ5WkgR7ECrkl1mD+
         Z0D9QSX0hOLv5RxMqhe4wMdkcr6htmcUssFVNvsqI2p2sZUV2sSqC/dxX8MlotBmoPyS
         1WtaRe4XdlWkUG0IjyeBjS3KE/bvHMmfVMEDI2+M8krVyWlpRdhOQoAsSyvoTAQ2rhmk
         ilVHEgYv0sHK8Jzh+8D9WN61t7I5W8NnUonpYVin/bat43MTIcAV28QRmqZFbZxFDiAe
         9xVxmq8XT0TZm05PzATXxd+5R13N6679AnV0Cz6503ohojwdrgpexhDbP0po1hSkSdhK
         C4yQ==
X-Gm-Message-State: ALoCoQnkSf4JzSWnx/n2UQtWqb0XIjgj8JSQTCO2CXtsAagLP8to/JlMuGR0GB5lLrV0UTtJcoRp
X-Received: by 10.236.89.15 with SMTP id b15mr5901176yhf.13.1393783706905;
        Sun, 02 Mar 2014 10:08:26 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.102.7 with SMTP id fk7ls1523529igb.8.canary; Sun, 02 Mar
 2014 10:08:25 -0800 (PST)
X-Received: by 10.66.220.198 with SMTP id py6mr15022718pac.21.1393783705405;
        Sun, 02 Mar 2014 10:08:25 -0800 (PST)
Original-Received: from mail-pb0-x229.google.com (mail-pb0-x229.google.com [2607:f8b0:400e:c01::229])
        by mx.google.com with ESMTPS id se8si8017513pbb.246.2014.03.02.10.08.25
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Sun, 02 Mar 2014 10:08:25 -0800 (PST)
Received-SPF: pass (google.com: domain of potswa@gmail.com designates 2607:f8b0:400e:c01::229 as permitted sender) client-ip=2607:f8b0:400e:c01::229;
Original-Received: by mail-pb0-f41.google.com with SMTP id jt11so2833144pbb.14
        for <std-proposals@isocpp.org>; Sun, 02 Mar 2014 10:08:25 -0800 (PST)
X-Received: by 10.66.197.135 with SMTP id iu7mr677266pac.149.1393783705271;
        Sun, 02 Mar 2014 10:08:25 -0800 (PST)
Original-Received: from [172.20.10.2] ([121.54.54.55])
        by mx.google.com with ESMTPSA id g6sm66481789pat.2.2014.03.02.10.08.20
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Sun, 02 Mar 2014 10:08:24 -0800 (PST)
In-Reply-To: <CAFk2RUafGLPR+o1hFtBJjS7Ho0Ms1_q-Mtazsf5jp8CFF-5qqA@mail.gmail.com>
X-Mailer: Apple Mail (2.1874)
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:c01::229 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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:9493
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/9493>

--Apple-Mail=_81527C4F-4DFC-41C0-9493-29580E16A543
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On Mar 3, 2014, at 1:47 AM, Ville Voutilainen <ville.voutilainen@gmail.com>=
 wrote:

> Well, good point, but I now realize that it's not an artifact of having t=
o
> deduce the type, but an artifact of having to be able to return the type
> from a factory type.

Well, the factory only exists to perform deduction. But moving on...

> Urgh.

So, move construction does not need to be allowed, if auto && is required. =
This is the better design choice. For comparison, the original scope_guard =
required use of const & to get around C++03 limitations of initialization a=
nd persistence in the absence of auto.

It's also the only way a guard can work without that internal Boolean flag,=
 which is necessary to make the usually-elided move constructor do the righ=
t thing.

>> 3) I find the naming of the types and factory functions inconsistent
>> with the rest of the standard.
>> The proposal notes that this is because the guard isn't supposed to be
>> treated as an object.
>=20
> Well, unique_resource most certainly _will_ be treated as an object.
> And not everybody will use auto with it. People will store unique_resourc=
es
> in containers.

Agreed. Actually the given justification is "because they actually do not a=
llocate any resources, like std::make_unique or std::make_shared do." But t=
here are other non-allocating factory functions like make_tuple. My brain q=
uietly substituted "object" for "resource."

>> What's the point of the restriction anyway? R will seldom if ever be
>> anything besides a pointer or class, and the operator-> definition is
>> well-formed for any copyable R. (Non-copyable objects are always classes
>> anyway.)
>=20
> operator-> is not valid for a resource that holds an int, for example.

That wouldn't be much of a resource. Anyway, as I said, the member declarat=
ion, and function body, are still valid. GCC and Clang -pedantic don't warn=
 about such a declaration. It's useless, but harmless. (On the other hand, =
we've already had a bug with the SFINAE here ;v) .)

--=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=_81527C4F-4DFC-41C0-9493-29580E16A543
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 Mar 3=
, 2014, at 1:47 AM, Ville Voutilainen &lt;<a href=3D"mailto:ville.voutilain=
en@gmail.com">ville.voutilainen@gmail.com</a>&gt; wrote:</div><br class=3D"=
Apple-interchange-newline"><blockquote type=3D"cite">Well, good point, but =
I now realize that it's not an artifact of having to<br>deduce the type, bu=
t an artifact of having to be able to return the type<br>from a factory typ=
e.</blockquote><div><br></div><div>Well, the factory only exists to perform=
 deduction. But moving on&hellip;</div><br><blockquote type=3D"cite">Urgh.<=
br></blockquote><div><br></div><div>So, move construction does not need to =
be allowed, if <font face=3D"Courier">auto &amp;&amp;</font> is required. T=
his is the better design choice. For comparison, the original <font face=3D=
"Courier">scope_guard</font> required use of&nbsp;<font face=3D"Courier">co=
nst &amp;</font>&nbsp;to get around C++03 limitations of initialization and=
 persistence in the absence of <font face=3D"Courier">auto</font>.</div><di=
v><br></div><div>It&rsquo;s also the only way a guard can work without that=
 internal Boolean flag, which is necessary to make the usually-elided move =
constructor do the right thing.</div><br><blockquote type=3D"cite"><blockqu=
ote type=3D"cite">3) I find the naming of the types and factory functions i=
nconsistent<br>with the rest of the standard.<br>The proposal notes that th=
is is because the guard isn't supposed to be<br>treated as an object.<br></=
blockquote><br>Well, unique_resource most certainly _will_ be treated as an=
 object.<br>And not everybody will use auto with it. People will store uniq=
ue_resources<br>in containers.<br></blockquote><div><br></div>Agreed. Actua=
lly the given justification is "because  they  actually  do  not  allocate =
 any  resources,&nbsp;like <font face=3D"Courier">std::make_unique</font>&n=
bsp;or&nbsp;<font face=3D"Courier">std::make_shared</font> do.&rdquo; But t=
here are other non-allocating factory functions like <font face=3D"Courier"=
>make_tuple</font>. My brain quietly substituted &ldquo;object&rdquo; for &=
ldquo;resource.&rdquo;</div><div><br><blockquote type=3D"cite"><blockquote =
type=3D"cite">What's the point of the restriction anyway? R will seldom if =
ever be</blockquote><blockquote type=3D"cite">anything besides a pointer or=
 class, and the operator-&gt; definition is<br>well-formed for any copyable=
 R. (Non-copyable objects are always classes<br>anyway.)<br></blockquote><b=
r>operator-&gt; is not valid for a resource that holds an int, for example.=
<br></blockquote><div><br></div>That wouldn&rsquo;t be much of a resource. =
Anyway, as I said, the member declaration, and function body, are still val=
id. GCC and Clang <font face=3D"Courier">-pedantic</font> don&rsquo;t warn =
about such a declaration. It&rsquo;s useless, but harmless. (On the other h=
and, we&rsquo;ve already had a bug with the SFINAE here ;v) .)</div><div><b=
r></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=_81527C4F-4DFC-41C0-9493-29580E16A543--

.
