220 11849 <DABFDEB7-ADF9-40EC-B4DB-672205A99FEB@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 17:29:40 +0800
Lines: 104
Approved: news@gmane.org
Message-ID: <DABFDEB7-ADF9-40EC-B4DB-672205A99FEB@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>
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=_5DB44DB9-2EAB-46AD-AF6E-4FB2EB298B76"
X-Trace: ger.gmane.org 1405070999 2919 80.91.229.3 (11 Jul 2014 09:29:59 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 11 Jul 2014 09:29:59 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCW25A7E3QCRBDO572OQKGQELWYJEGY@isocpp.org Fri Jul 11 11:29:52 2014
Return-path: <std-proposals+bncBCW25A7E3QCRBDO572OQKGQELWYJEGY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f200.google.com ([209.85.214.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCW25A7E3QCRBDO572OQKGQELWYJEGY@isocpp.org>)
	id 1X5X9L-0005A0-9l
	for gclcip-std-proposals@m.gmane.org; Fri, 11 Jul 2014 11:29:51 +0200
Original-Received: by mail-ob0-f200.google.com with SMTP id nu7sf4159205obb.11
        for <gclcip-std-proposals@m.gmane.org>; Fri, 11 Jul 2014 02:29:50 -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=MehNiBvPD9Nugi5OvmztbEq7tvhPP2uPkKQMEPrCn9M=;
        b=MauC/pkIy4/NGm5NthykKz7DfOVlXZ/AXQKwfacg7L2cPWhnBNxe1Ie8CO2x8fUC4u
         HPgPTYO2KGjVwvmF12xDNI4mzzGLwFmCzJk1NDHD6MSsGT9vCF3WYuonagHsyd769o60
         X5O3ayHsSxxbl6exRQ3z4zO59ZmVAAFRdomJIAlP3lrZo90hTFfbEYzi2I0AY17mQpJF
         Nwt0KAQPqwDfQL/Wk4ShS/XJA6+yCBfGIPf3UcISvCKTLIMbno5tTK8O0e6FGEwqLkk6
         183tZHBCh0aUutZG8Y8v8zEpi/fnzRkfSXAFemLaGHSljwUD3Pgfhstkc8jzUCq7W/ld
         l6wg==
X-Gm-Message-State: ALoCoQn2WFE2vateHzjFw4FNIkA2ez1GrW8Xnhg+nJUozOI+xOU6RJy4kxl4yHMcjxLeacvVf6qT
X-Received: by 10.42.151.67 with SMTP id d3mr1495182icw.6.1405070990183;
        Fri, 11 Jul 2014 02:29:50 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.79.135 with SMTP id j7ls310585igx.6.canary; Fri, 11 Jul
 2014 02:29:49 -0700 (PDT)
X-Received: by 10.50.79.232 with SMTP id m8mr2737835igx.33.1405070989005;
        Fri, 11 Jul 2014 02:29:49 -0700 (PDT)
Original-Received: from mail-ig0-x229.google.com (mail-ig0-x229.google.com [2607:f8b0:4001:c05::229])
        by mx.google.com with ESMTPS id hs3si2359673igb.51.2014.07.11.02.29.48
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Fri, 11 Jul 2014 02:29:49 -0700 (PDT)
Received-SPF: pass (google.com: domain of potswa@gmail.com designates 2607:f8b0:4001:c05::229 as permitted sender) client-ip=2607:f8b0:4001:c05::229;
Original-Received: by mail-ig0-f169.google.com with SMTP id r10so351083igi.2
        for <std-proposals@isocpp.org>; Fri, 11 Jul 2014 02:29:48 -0700 (PDT)
X-Received: by 10.43.140.193 with SMTP id jb1mr3205334icc.15.1405070988890;
        Fri, 11 Jul 2014 02:29:48 -0700 (PDT)
Original-Received: from [172.20.10.2] ([121.54.54.43])
        by mx.google.com with ESMTPSA id hv1sm1428938igb.0.2014.07.11.02.29.45
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Fri, 11 Jul 2014 02:29:48 -0700 (PDT)
In-Reply-To: <CAOenAXiBW+BiUkPWdGQHS9fkyEVWJg343NXH9kRSn9owk6FmgQ@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::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: <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:11849
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11849>

--Apple-Mail=_5DB44DB9-2EAB-46AD-AF6E-4FB2EB298B76
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1


On 2014-07-11, at 5:09 PM, Andrzej Krzemienski <akrzemi1@gmail.com> wrote:

> 2014-07-11 11:02 GMT+02:00 David Krauss <potswa@gmail.com>:
> As was discussed earlier, return-by-xvalue does not work with local unive=
rsal references. Universal references are not just a cute thing that trendy=
 programmers like to sprinkle around, they provide a way for generic code t=
o bind a name to something which may or may not be a reference.
>=20
> David, would it be possible to illustrate with an example what you mean h=
ere?

template< typename container_handle >
void operate_on_fifth_thing( container_handle && ch ) {
    // Save only the fifth element. We don't need the rest; OK to free thos=
e resources.
    auto && fifth_thing =3D=3D ( * std::forward< container_handle >( ch ) )=
[ 5 ];

    // This is illustrated as a function call, but there might as well be a=
 loop here.
    process_for_a_long_time( std::forward< decltype( thing ) >( fifth_thing=
 ) );
}

I don't think this is far-fetched at all, aside from presupposing rvalue-ov=
erloaded operator* and operator[].

You generally might do the same things with a named object as with a tempor=
ary. "Forwarding contexts" don't all end at the semicolon.

--=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=_5DB44DB9-2EAB-46AD-AF6E-4FB2EB298B76
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:09 PM, Andrzej Krzemienski &lt;<a href=3D"mailto:ak=
rzemi1@gmail.com">akrzemi1@gmail.com</a>&gt; wrote:</div><br class=3D"Apple=
-interchange-newline"><blockquote type=3D"cite"><div dir=3D"ltr">2014-07-11=
 11:02 GMT+02:00 David Krauss <span dir=3D"ltr">&lt;<a href=3D"mailto:potsw=
a@gmail.com" target=3D"_blank">potswa@gmail.com</a>&gt;</span>:<br><div cla=
ss=3D"gmail_extra"><div class=3D"gmail_quote">
<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; borde=
r-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style=
: solid; padding-left: 1ex; position: static; z-index: auto;"><div class=3D=
"">As was discussed earlier, return-by-xvalue does not work with local univ=
ersal references. Universal references are not just a cute thing that trend=
y programmers like to sprinkle around, they provide a way for generic code =
to bind a name to something which may or may not be a reference.</div>
</blockquote><div><br></div><div>David, would it be possible to illustrate =
with an example what you mean here?<br></div></div></div></div></blockquote=
></div><br><div><font face=3D"Courier">template&lt; typename container_hand=
le &gt;</font></div><div><font face=3D"Courier">void operate_on_fifth_thing=
( container_handle &amp;&amp; ch ) {</font></div><div><font face=3D"Courier=
">&nbsp; &nbsp; // Save only the fifth element. We don&rsquo;t need the res=
t; OK to free those resources.</font></div><div><font face=3D"Courier">&nbs=
p; &nbsp; auto &amp;&amp; fifth_thing =3D=3D ( * std::forward&lt; container=
_handle &gt;( ch ) )[ 5 ];</font></div><div><font face=3D"Courier"><br></fo=
nt></div><div><font face=3D"Courier">&nbsp; &nbsp; // This is illustrated a=
s a function call, but there might as well be a loop here.</font></div><div=
><font face=3D"Courier">&nbsp; &nbsp; process_for_a_long_time( std::forward=
&lt; decltype( thing ) &gt;( fifth_thing ) );</font></div><div><font face=
=3D"Courier">}</font></div><div><br></div><div>I don&rsquo;t think this is =
far-fetched at all, aside from presupposing rvalue-overloaded <font face=3D=
"Courier">operator*</font> and <font face=3D"Courier">operator[]</font>.</d=
iv><div><br></div><div>You generally might do the same things with a named =
object as with a temporary. &ldquo;Forwarding contexts&rdquo; don&rsquo;t a=
ll end at the semicolon.</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=_5DB44DB9-2EAB-46AD-AF6E-4FB2EB298B76--

.
