220 11858 <6B925FF7-2940-44C7-BF1D-13209A703BA2@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: N4078: Rvalue reference overloads for value()
 method returns object by value
Date: Fri, 11 Jul 2014 18:21:20 +0800
Lines: 123
Approved: news@gmane.org
Message-ID: <6B925FF7-2940-44C7-BF1D-13209A703BA2@gmail.com>
References: <b538efba-faf4-4ffc-a553-302b9d2ba2c0@isocpp.org>
 <CANh-dX=M7niArNp-1sCcqxaREEJSxmjMftgw7uMHN9YnZC-h+w@mail.gmail.com>
 <4DA018C3-2327-4F55-B7F8-7988EC7B789A@gmail.com> <1a858a77-310b-4591-aaf5-960c40d9f5fc@isocpp.org>
 <66AF41C1-CB37-4311-98EA-D47DBC6068DC@gmail.com> <66c38b61-7a95-4ace-b34f-2346bb334fb9@isocpp.org>
 <F1CBA358-0AD8-4ADD-99DA-6D00FCFE150F@gmail.com> <CAFk2RUZENmaMW5NwBaiF6byfhgRyPUsSmuyVjnRDhbjcfaTtQA@mail.gmail.com>
 <CC03CC1C-8487-40C8-97DF-2CA7661DAD55@gmail.com> <CAFk2RUa7-WTcL=XFYO8KMyU4rdpjDEfFM6n6SkUZ=SW_U7s5XQ@mail.gmail.com>
 <EF930317-EB97-402E-A3A0-CC46E7E2D998@gmail.com> <CAFk2RUZigiwLwFpfVXuFS8cqy38hPG3OGhGUi+iNwSYuYvyAyQ@mail.gmail.com>
 <A46ADDB4-C9B0-4163-81BE-900CD879D8C8@gmail.com> <CAFk2RUZ-DqEcMeehjH8KedYgErxKMq4O9kmeN4FZzjkXMYSsiw@mail.gmail.com>
 <6F4B3C72-9962-48DC-8527-0C89EA1B9710@gmail.com> <CAFk2RUb5xynaoQx-j4cQuXC8t-0GGc9-CZyRA2V=j6cfuNQV=g@mail.gmail.com>
 <35873CE5-ED8C-4C03-A6A1-E4132DECD91F@gmail.com> <CAFk2RUYRJSNcXykj9oPd=3EehSozf7PcX8ACM_hrqhK+Ur2V8A@mail.gmail.com>
 <335948E6-8140-4673-B958-930356A52070@gmail.com> <CAFk2RUYf+tpBvxiK00O=FncB01BWe6+SXiYBN7fixd4mhm+Z-w@mail.gmail.com>
 <76ACA175-5A44-4BE8-B49F-BAC6DA65E6B1@gmail.com> <CAFk2RUah5k9zy_mQqeNN9mec0PYkmKDZp7LVXm64dTeSLaw6nQ@mail.gmail.com>
 <4D3852AD-1AEB-44BA-941C-D645BAD19405@gmail.com> <6a4b6425-1167-40c1-acd8-3945c8cd4c74@isocpp.org>
 <13DD0D7A-A146-4667-9F30-6FB3739CDBE0@gmail.com> <CADGW59=9uFv-fXRVuBCE+3fdycqTzaqCJnuVmmaT6mOF=1=-MA@mail.gmail.com>
 <E9F36B2C-A142-4B6C-ADFD-57D0E11F2C5B@gmail.com> <CAOenAXiBW+BiUkPWdGQHS9fkyEVWJg343NXH9kRSn9owk6FmgQ@mail.gmail.com>
 <DABFDEB7-ADF9-40EC-B4DB-672205A99FEB@gmail.com> <CAFk2RUa-kPWGy29siK4dUu6jbydfwbUeuzCpYOi+b9xc4-msSg@mail.gmail.com>
 <C3BA0F43-683E-4FFE-B04C-9015EB9C7CB0@gmail.com> <CAFk2RUYzt26HjKhYCZtJ4BMrjLzu9MQvZ0ynuaULWTYbE6MBAA@mail.gmail.com>
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=_206A06F3-E0CE-407B-B5C7-CD2D5E009A6A"
X-Trace: ger.gmane.org 1405074096 7805 80.91.229.3 (11 Jul 2014 10:21:36 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 11 Jul 2014 10:21:36 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCW25A7E3QCRBKHV72OQKGQEECA2HKA@isocpp.org Fri Jul 11 12:21:29 2014
Return-path: <std-proposals+bncBCW25A7E3QCRBKHV72OQKGQEECA2HKA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ig0-f198.google.com ([209.85.213.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCW25A7E3QCRBKHV72OQKGQEECA2HKA@isocpp.org>)
	id 1X5XxJ-0006oq-DP
	for gclcip-std-proposals@m.gmane.org; Fri, 11 Jul 2014 12:21:29 +0200
Original-Received: by mail-ig0-f198.google.com with SMTP id h18sf2863821igc.1
        for <gclcip-std-proposals@m.gmane.org>; Fri, 11 Jul 2014 03:21:28 -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=4dvqIodqkai2MGNpMjALiZdGjZNUbM4O9nmgLjSKkrI=;
        b=auvj6bIVK5O7LAW8pv83LVMnVyihxuSKNQhZhVFyLyIS7IjdEbS0h1kItEC/0kZQn6
         +pb75x/HIFBhyuHlp0Rrby4H/rN2DnvmQNxlacKcj2uI1NPfoOFZhMGhRR+NQkj7iGfQ
         F8UXXvIrF6NrOL8iB8JnsD9cC0iUULrgDXz8USD8Jz3Lq6CGWEWLD++4kSsuSTWo46Mo
         PwrocXj+Qu5VoZYp6+ExlRfnxo/rjQKPD4Unof22lCyWiVjoFvt2SUlr7Exrx2JvpBeN
         dkg6j45gFL+9Xo00wWopurkeRlaHkkI4wxW+Xb1a4ao9qnIpdxJSItNxwQXfsfxCVDUn
         6sBQ==
X-Gm-Message-State: ALoCoQk6V2LSJe5Wm/ENrZO1Boiv2wbK7esRELsboY7/Fm/E5tCQZiTuOqnM62u136R+mncqFQyP
X-Received: by 10.43.70.132 with SMTP id yg4mr1608289icb.30.1405074088531;
        Fri, 11 Jul 2014 03:21:28 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.138.193 with SMTP id qs1ls278152igb.43.canary; Fri, 11 Jul
 2014 03:21:28 -0700 (PDT)
X-Received: by 10.42.139.4 with SMTP id e4mr3265557icu.73.1405074088002;
        Fri, 11 Jul 2014 03:21:28 -0700 (PDT)
Original-Received: from mail-ig0-x22e.google.com (mail-ig0-x22e.google.com [2607:f8b0:4001:c05::22e])
        by mx.google.com with ESMTPS id e3si2623078igx.4.2014.07.11.03.21.27
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Fri, 11 Jul 2014 03:21:27 -0700 (PDT)
Received-SPF: pass (google.com: domain of potswa@gmail.com designates 2607:f8b0:4001:c05::22e as permitted sender) client-ip=2607:f8b0:4001:c05::22e;
Original-Received: by mail-ig0-f174.google.com with SMTP id c1so4096534igq.1
        for <std-proposals@isocpp.org>; Fri, 11 Jul 2014 03:21:27 -0700 (PDT)
X-Received: by 10.51.16.197 with SMTP id fy5mr3016528igd.47.1405074087871;
        Fri, 11 Jul 2014 03:21:27 -0700 (PDT)
Original-Received: from [172.20.10.2] ([121.54.54.152])
        by mx.google.com with ESMTPSA id p12sm4704319igx.18.2014.07.11.03.21.25
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Fri, 11 Jul 2014 03:21:27 -0700 (PDT)
In-Reply-To: <CAFk2RUYzt26HjKhYCZtJ4BMrjLzu9MQvZ0ynuaULWTYbE6MBAA@mail.gmail.com>
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:4001:c05::22e 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:11858
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11858>

--Apple-Mail=_206A06F3-E0CE-407B-B5C7-CD2D5E009A6A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-07-11, at 5:47 PM, Ville Voutilainen <ville.voutilainen@gmail.com> =
wrote:

> On 11 July 2014 12:36, David Krauss <potswa@gmail.com> wrote:
>>=20
>> On 2014-07-11, at 5:34 PM, Ville Voutilainen <ville.voutilainen@gmail.co=
m> wrote:
>>=20
>>> Why is that code using auto&&?
>>=20
>> Can you rewrite it with any other substitute?
>=20
>=20
> That would depend on the answer to the question. The container is not
> going out of scope,

The pattern I intended to illustrate is, "take a one-liner using std::forwa=
rd and divide it over two lines by adding a named variable." If I'd passed =
ch to a function, it could well get moved-from.

A more straightforward example is simply naming the result of a generic fun=
ction.

auto && result =3D q( std::forward< V >( v ) );

Using auto instead of auto && may produce an unnecessary copy. No, it doesn=
't work if q returns an expiring reference, but yes, it does if q guarantee=
s it won't. It's possible, and good, to write libraries that don't have exp=
iring return values, regardless of what someone else did and the pain felt =
by their users.

Indeed, the question could go either way. Both alternatives introduce probl=
ems, which anyway may be worked around. I could create a generic function s=
ave_xvalue() to catch such and copy into a prvalue, and use that as an adap=
tor to auto &&. However, I think component-forwarding should get stuck with=
 the workaround because it's more esoteric than auto &&.

> I see nothing new that would be convincing to change the understanding
> I have about what
> we should do for the rvalue-ref-qualified observer overloads of optional.

Well, at least we see eye-to-eye. I hope you're right about the TS not carr=
ying a lock-in effect. The only responsible way to resolve this dilemma for=
 the entire library is with thorough review in a proper context.

--=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=_206A06F3-E0CE-407B-B5C7-CD2D5E009A6A
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;07&ndash;11, at 5:47 PM, Ville Voutilainen &lt;<a href=3D"mailto:vill=
e.voutilainen@gmail.com">ville.voutilainen@gmail.com</a>&gt; wrote:</div><b=
r class=3D"Apple-interchange-newline"><blockquote type=3D"cite">On 11 July =
2014 12:36, David Krauss &lt;<a href=3D"mailto:potswa@gmail.com">potswa@gma=
il.com</a>&gt; wrote:<br><blockquote type=3D"cite"><br>On 2014-07-11, at 5:=
34 PM, Ville Voutilainen &lt;<a href=3D"mailto:ville.voutilainen@gmail.com"=
>ville.voutilainen@gmail.com</a>&gt; wrote:<br><br><blockquote type=3D"cite=
">Why is that code using auto&amp;&amp;?<br></blockquote><br>Can you rewrit=
e it with any other substitute?<br></blockquote><br><br>That would depend o=
n the answer to the question. The container is not<br>going out of scope,<b=
r></blockquote><div><br></div><div>The pattern I intended to illustrate is,=
 &ldquo;take a one-liner using std::forward and divide it over two lines by=
 adding a named variable.&rdquo; If I&rsquo;d passed <font face=3D"Courier"=
>ch</font> to a function, it could well get moved-from.</div><div><br></div=
><div>A more straightforward example is simply naming the result of a gener=
ic function.</div><div><br></div><div><font face=3D"Courier">auto &amp;&amp=
; result =3D q( std::forward&lt; V &gt;( v ) );</font></div><div><br></div>=
<div>Using&nbsp;<font face=3D"Courier">auto</font> instead of <font face=3D=
"Courier">auto &amp;&amp;</font>&nbsp;may produce an unnecessary copy. No, =
it doesn&rsquo;t work if q returns an expiring reference, but yes, it does =
if q guarantees it won&rsquo;t. It&rsquo;s possible, and good, to write lib=
raries that don&rsquo;t have expiring return values, regardless of what som=
eone else did and the pain felt by their users.</div><div><br></div><div>In=
deed, the question could go either way. Both alternatives introduce problem=
s, which anyway may be worked around. I could create a generic function <fo=
nt face=3D"Courier">save_xvalue()</font>&nbsp;to catch such and copy into a=
 prvalue, and use that as an adaptor to <font face=3D"Courier">auto &amp;&a=
mp;</font>. However, I think component-forwarding should get stuck with the=
 workaround because it&rsquo;s more esoteric than <font face=3D"Courier">au=
to &amp;&amp;</font>.</div><br><blockquote type=3D"cite">I see nothing new =
that would be convincing to change the understanding<br>I have about what<b=
r>we should do for the rvalue-ref-qualified observer overloads of optional.=
<br></blockquote></div><br><div>Well, at least we see eye-to-eye. I hope yo=
u&rsquo;re right about the TS not carrying a lock-in effect. The only respo=
nsible way to resolve this dilemma for the entire library is with thorough =
review in a proper context.</div><div><br></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=_206A06F3-E0CE-407B-B5C7-CD2D5E009A6A--

.
