220 11851 <DB94F7D6-D131-439C-A05E-83FA5335171F@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:36:03 +0800
Lines: 114
Approved: news@gmane.org
Message-ID: <DB94F7D6-D131-439C-A05E-83FA5335171F@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=_D9B675E4-E67D-49EA-A350-7A0FA65E0481"
X-Trace: ger.gmane.org 1405071382 7031 80.91.229.3 (11 Jul 2014 09:36:22 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 11 Jul 2014 09:36:22 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCW25A7E3QCRBDHA72OQKGQEYY4I52Y@isocpp.org Fri Jul 11 11:36:14 2014
Return-path: <std-proposals+bncBCW25A7E3QCRBDHA72OQKGQEYY4I52Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yk0-f199.google.com ([209.85.160.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCW25A7E3QCRBDHA72OQKGQEYY4I52Y@isocpp.org>)
	id 1X5XFV-0003NR-DT
	for gclcip-std-proposals@m.gmane.org; Fri, 11 Jul 2014 11:36:13 +0200
Original-Received: by mail-yk0-f199.google.com with SMTP id 200sf2081774ykr.10
        for <gclcip-std-proposals@m.gmane.org>; Fri, 11 Jul 2014 02:36:12 -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=ih+kZC0fFEfGap98EdFvQcatAXiEgs3fQ+BzK8UI8Ls=;
        b=jC4RXTzeja3xKEwSqwxWWCk3W53/3D0ROi05FP5xpXge5mR4wqEYZvYWIhwjG85qqC
         zHzZUi3adjL2G7Bd6hJkWE5rjCoW7wG2zT/EkMPpP0V/cZeEpowgeCc0rAtzMb/tauGW
         OGJ1s8vvFJcyg2CTJbGqKMGQFdN1LP1C8o3BoZWW5z0fTxFlH5GnjC/aik/WRasjKhWt
         03C10hCr5MuOhqP8lSagsVOx6Ts5SFGQKK1wzEI6Nlja7QFg6XNuHKRGAQLazsr04zZT
         CrJkpcUMmLXj7nJXFretqqh7gws9pJyuPHZT8+tPPziaU36E8XweuXSZb2xRgGpIcAVO
         FcEA==
X-Gm-Message-State: ALoCoQnz0wllS/DHIsXl6MRZ69N80nXjtUO5nSxjscHRnnPj+VBdQSYlQ92fHWQazDNFCn+zGDV2
X-Received: by 10.236.14.99 with SMTP id c63mr22759283yhc.40.1405071372574;
        Fri, 11 Jul 2014 02:36:12 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.136.168 with SMTP id qb8ls265934igb.43.gmail; Fri, 11 Jul
 2014 02:36:12 -0700 (PDT)
X-Received: by 10.50.25.130 with SMTP id c2mr2905646igg.7.1405071371994;
        Fri, 11 Jul 2014 02:36:11 -0700 (PDT)
Original-Received: from mail-ie0-x22b.google.com (mail-ie0-x22b.google.com [2607:f8b0:4001:c03::22b])
        by mx.google.com with ESMTPS id ii2si2382087igb.62.2014.07.11.02.36.11
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Fri, 11 Jul 2014 02:36:11 -0700 (PDT)
Received-SPF: pass (google.com: domain of potswa@gmail.com designates 2607:f8b0:4001:c03::22b as permitted sender) client-ip=2607:f8b0:4001:c03::22b;
Original-Received: by mail-ie0-f171.google.com with SMTP id at1so682985iec.2
        for <std-proposals@isocpp.org>; Fri, 11 Jul 2014 02:36:11 -0700 (PDT)
X-Received: by 10.42.239.196 with SMTP id kx4mr3041825icb.71.1405071371860;
        Fri, 11 Jul 2014 02:36:11 -0700 (PDT)
Original-Received: from [172.20.10.2] ([121.54.54.43])
        by mx.google.com with ESMTPSA id qa4sm4456543igb.10.2014.07.11.02.36.09
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Fri, 11 Jul 2014 02:36:11 -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:c03::22b 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:11851
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11851>

--Apple-Mail=_D9B675E4-E67D-49EA-A350-7A0FA65E0481
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?


I've adjusted the comments slightly, just for exposition of what forwarding=
 in this case actually does.

template< typename container_handle >
void operate_on_fifth_thing( container_handle && ch ) {
    // Get only the fifth element. We don't need the rest; OK to free those=
 resources.
    // However, if not assuming ownership, there's no need to make a copy.
    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=_D9B675E4-E67D-49EA-A350-7A0FA65E0481
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"><meta http-equiv=3D"Content-Type" content=3D"text/html cha=
rset=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-n=
bsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2=
014&ndash;07&ndash;11, at 5:09 PM, Andrzej Krzemienski &lt;<a href=3D"mailt=
o:akrzemi1@gmail.com">akrzemi1@gmail.com</a>&gt; wrote:</div><br class=3D"A=
pple-interchange-newline"><blockquote type=3D"cite"><div dir=3D"ltr">2014-0=
7-11 11:02 GMT+02:00 David Krauss <span dir=3D"ltr">&lt;<a href=3D"mailto:p=
otswa@gmail.com" target=3D"_blank">potswa@gmail.com</a>&gt;</span>:<br><div=
 class=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><div><br></div><div>I&rsquo;ve adjusted the comments slightly, just =
for exposition of what forwarding in this case actually does.</div><br><div=
><font face=3D"Courier">template&lt; typename container_handle &gt;</font><=
/div><div><font face=3D"Courier">void operate_on_fifth_thing( container_han=
dle &amp;&amp; ch ) {</font></div><div><font face=3D"Courier">&nbsp; &nbsp;=
 // Get only the fifth element. We don&rsquo;t need the rest; OK to free th=
ose resources.</font></div><div><font face=3D"Courier">&nbsp; &nbsp; // How=
ever, if not assuming ownership, there&rsquo;s no need to make a&nbsp;copy.=
</font></div><div><font face=3D"Courier">&nbsp; &nbsp; auto &amp;&amp; fift=
h_thing =3D=3D ( * std::forward&lt; container_handle &gt;( ch ) )[ 5 ];</fo=
nt></div><div><font face=3D"Courier"><br></font></div><div><font face=3D"Co=
urier">&nbsp; &nbsp; // This is illustrated as a function call, but there m=
ight 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;( f=
ifth_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 p=
resupposing rvalue-overloaded <font face=3D"Courier">operator*</font> and <=
font face=3D"Courier">operator[]</font>.</div><div><br></div><div>You gener=
ally might do the same things with a named object as with a temporary. &ldq=
uo;Forwarding contexts&rdquo; don&rsquo;t all end at the semicolon.</div><d=
iv><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=_D9B675E4-E67D-49EA-A350-7A0FA65E0481--

.
