220 21337 <2C19913E-B6BC-423D-8570-939C3A573CDF@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: Re: Conversion from lvalue to rvalue
Date: Tue, 6 Oct 2015 15:34:54 +0800
Lines: 134
Approved: news@gmane.org
Message-ID: <2C19913E-B6BC-423D-8570-939C3A573CDF@gmail.com>
References: <f8a1e157-ae9a-40f8-9bc1-5aff59eefc10@isocpp.org> <31dedac5-7d51-402c-946e-0555c925f70d@isocpp.org> <d165db3c-7593-4663-b93e-c37eb8628635@isocpp.org> <116a66a2-90ea-4269-ac85-3432ff7094b0@isocpp.org> <42447957-4276-4f59-89b6-ab4be37c47c6@isocpp.org> <ff062d43-3aa3-4d6d-8c64-a2582e7d0ca8@isocpp.org> <BLU437-SMTP37170683138BE594B7E3E1A7370@phx.gbl>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\))
Content-Type: multipart/alternative; boundary="Apple-Mail=_D01DCD90-2953-4100-9334-C1E4B27ABB33"
X-Trace: ger.gmane.org 1444116910 14909 80.91.229.3 (6 Oct 2015 07:35:10 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 6 Oct 2015 07:35:10 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCW25A7E3QCRBJPTZWYAKGQEJBFHO2Y@isocpp.org Tue Oct 06 09:35:05 2015
Return-path: <std-proposals+bncBCW25A7E3QCRBJPTZWYAKGQEJBFHO2Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pd0-f197.google.com ([209.85.192.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCW25A7E3QCRBJPTZWYAKGQEJBFHO2Y@isocpp.org>)
	id 1ZjMm8-0006Hb-Ib
	for gclcip-std-proposals@m.gmane.org; Tue, 06 Oct 2015 09:35:05 +0200
Original-Received: by pdnr2 with SMTP id r2sf365159807pdn.0
        for <gclcip-std-proposals@m.gmane.org>; Tue, 06 Oct 2015 00:35:02 -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:content-type: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:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=aDeA9S5hZfQknTJuxd00p8GN2kfO/gNEqXut0+SCN2M=;
        b=fs0cp5kYDc8c5oEq/Ksid5iG7txi4ZdAOcVY8+gwg88LM6MPvnu+9fnnSW/8Z9Sjn1
         WYJ7yumMQkHZkn3Blm3bi20xk08qrADtrSYu0sdxyYL7ojcIeiN1PRTz/wbrFZDh/056
         N2BlDUNPZIID02HbBrPZQ+HBY4XWsxmIc5+fUMRWUprjFKzeHXnbNIH9E6RHKVl0r3yG
         2oskpXUfZ/g2Oxbw8v9T9zBMqeQX0ESKHPaCSqSf45HNANRw/8HAgjDbpqYD2KXfQvv7
         bo0pHyL20VJLL/IZNC/yJxNLlq4N60KvPg4p9WuEEB6Wof/mEhxASBktB4ZKEUKPBTf2
         ulaQ==
X-Gm-Message-State: ALoCoQn81PECAjmjahvnHs2egEJ3K5hXpll+lsHrv7lbpaFdtiZHvEDXL/piZHM/K05uAynl0r0r
X-Received: by 10.68.248.137 with SMTP id ym9mr29678428pbc.14.1444116902371;
        Tue, 06 Oct 2015 00:35:02 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.12.194 with SMTP id 63ls1873027iom.103.gmail; Tue, 06 Oct
 2015 00:35:01 -0700 (PDT)
X-Received: by 10.66.121.110 with SMTP id lj14mr44956488pab.61.1444116901352;
        Tue, 06 Oct 2015 00:35:01 -0700 (PDT)
Original-Received: from mail-pa0-x234.google.com (mail-pa0-x234.google.com. [2607:f8b0:400e:c03::234])
        by mx.google.com with ESMTPS id i16si42560585pbq.81.2015.10.06.00.35.01
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 06 Oct 2015 00:35:01 -0700 (PDT)
Received-SPF: pass (google.com: domain of potswa@gmail.com designates 2607:f8b0:400e:c03::234 as permitted sender) client-ip=2607:f8b0:400e:c03::234;
Original-Received: by pacfv12 with SMTP id fv12so206390324pac.2
        for <std-proposals@isocpp.org>; Tue, 06 Oct 2015 00:35:01 -0700 (PDT)
X-Received: by 10.68.57.175 with SMTP id j15mr45490526pbq.34.1444116901153;
        Tue, 06 Oct 2015 00:35:01 -0700 (PDT)
Original-Received: from [172.20.10.2] ([121.54.44.89])
        by smtp.gmail.com with ESMTPSA id qn5sm31786449pac.41.2015.10.06.00.34.58
        for <std-proposals@isocpp.org>
        (version=TLSv1/SSLv3 cipher=OTHER);
        Tue, 06 Oct 2015 00:35:00 -0700 (PDT)
In-Reply-To: <BLU437-SMTP37170683138BE594B7E3E1A7370@phx.gbl>
X-Mailer: Apple Mail (2.2104)
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::234 as permitted
 sender) smtp.mailfrom=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-Spam-Checked-In-Group: 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:21337
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/21337>

--Apple-Mail=_D01DCD90-2953-4100-9334-C1E4B27ABB33
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9310=E2=80=9306, at 9:37 AM, Agust=C3=ADn K-ballo Berg=C3=
=A9 <kaballo86@hotmail.com> wrote:
>=20
> This would do wasteful copies from rvalues. If you look at 30.2.6 [thread=
..decaycopy] you'll see it's defined as:
>=20
>    template <class T> decay_t<T> decay_copy(T&& v)
>      { return std::forward<T>(v); }
>=20
> I guess `auto` would do too.


decay_copy would always perform a copy, from an lvalue, xvalue, or prvalue.

auto{} would allow copy elision for prvalue operands. It would copy lvalue,=
 xvalue, and derived-type prvalues.

The ideal solution would return only lvalues by value, and rvalues always b=
y reference. An overloaded function can do this, but the references would t=
end to dangle without lifetime extension of function operands a la P0066 <h=
ttp://wg21.link/P0066>. However, that still doesn=E2=80=99t (yet) cover ass=
ignment operations like to std::tie in the OP.

--=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=_D01DCD90-2953-4100-9334-C1E4B27ABB33
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9310=
=E2=80=9306, at 9:37 AM, Agust=C3=ADn K-ballo Berg=C3=A9 &lt;<a href=3D"mai=
lto:kaballo86@hotmail.com" class=3D"">kaballo86@hotmail.com</a>&gt; wrote:<=
/div><br class=3D"Apple-interchange-newline"><div class=3D""><span style=3D=
"font-family: Helvetica; font-size: 12px; font-style: normal; font-variant:=
 normal; font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: auto; text-align: start; text-indent: 0px; text-transform: none; w=
hite-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-wi=
dth: 0px; float: none; display: inline !important;" class=3D"">This would d=
o wasteful copies from rvalues. If you look at 30.2.6 [thread.decaycopy] yo=
u'll see it's defined as:</span><br style=3D"font-family: Helvetica; font-s=
ize: 12px; font-style: normal; font-variant: normal; font-weight: normal; l=
etter-spacing: normal; line-height: normal; orphans: auto; text-align: star=
t; text-indent: 0px; text-transform: none; white-space: normal; widows: aut=
o; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><br style=
=3D"font-family: Helvetica; font-size: 12px; font-style: normal; font-varia=
nt: normal; font-weight: normal; letter-spacing: normal; line-height: norma=
l; orphans: auto; text-align: start; text-indent: 0px; text-transform: none=
; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke=
-width: 0px;" class=3D""><span style=3D"font-family: Helvetica; font-size: =
12px; font-style: normal; font-variant: normal; font-weight: normal; letter=
-spacing: normal; line-height: normal; orphans: auto; text-align: start; te=
xt-indent: 0px; text-transform: none; white-space: normal; widows: auto; wo=
rd-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inli=
ne !important;" class=3D"">&nbsp;&nbsp;&nbsp;template &lt;class T&gt; decay=
_t&lt;T&gt; decay_copy(T&amp;&amp; v)</span><br style=3D"font-family: Helve=
tica; font-size: 12px; font-style: normal; font-variant: normal; font-weigh=
t: normal; letter-spacing: normal; line-height: normal; orphans: auto; text=
-align: start; text-indent: 0px; text-transform: none; white-space: normal;=
 widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D=
""><span style=3D"font-family: Helvetica; font-size: 12px; font-style: norm=
al; font-variant: normal; font-weight: normal; letter-spacing: normal; line=
-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-t=
ransform: none; white-space: normal; widows: auto; word-spacing: 0px; -webk=
it-text-stroke-width: 0px; float: none; display: inline !important;" class=
=3D"">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ return std::forward&lt;T&gt;(v); }</s=
pan><br style=3D"font-family: Helvetica; font-size: 12px; font-style: norma=
l; font-variant: normal; font-weight: normal; letter-spacing: normal; line-=
height: normal; orphans: auto; text-align: start; text-indent: 0px; text-tr=
ansform: none; white-space: normal; widows: auto; word-spacing: 0px; -webki=
t-text-stroke-width: 0px;" class=3D""><br style=3D"font-family: Helvetica; =
font-size: 12px; font-style: normal; font-variant: normal; font-weight: nor=
mal; letter-spacing: normal; line-height: normal; orphans: auto; text-align=
: start; text-indent: 0px; text-transform: none; white-space: normal; widow=
s: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><sp=
an style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; fo=
nt-variant: normal; font-weight: normal; letter-spacing: normal; line-heigh=
t: normal; orphans: auto; text-align: start; text-indent: 0px; text-transfo=
rm: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-tex=
t-stroke-width: 0px; float: none; display: inline !important;" class=3D"">I=
 guess `auto` would do too.</span><br style=3D"font-family: Helvetica; font=
-size: 12px; font-style: normal; font-variant: normal; font-weight: normal;=
 letter-spacing: normal; line-height: normal; orphans: auto; text-align: st=
art; text-indent: 0px; text-transform: none; white-space: normal; widows: a=
uto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""></div><=
/blockquote></div><div class=3D""><br class=3D""></div><div class=3D""><fon=
t face=3D"Courier" class=3D"">decay_copy</font> would always perform a copy=
, from an lvalue, xvalue, or prvalue.</div><div class=3D""><font face=3D"Co=
urier" class=3D""><br class=3D""></font></div><div class=3D""><font face=3D=
"Courier" class=3D"">auto{}</font> would allow copy elision for prvalue ope=
rands. It would copy lvalue, xvalue, and derived-type prvalues.</div><div c=
lass=3D""><br class=3D""></div><div class=3D"">The ideal solution would ret=
urn only lvalues by value, and rvalues always by reference. An overloaded f=
unction can do this, but the references would tend to dangle without lifeti=
me extension of function operands a la&nbsp;<a href=3D"http://wg21.link/P00=
66" class=3D"">P0066</a>. However, that still doesn=E2=80=99t (yet) cover a=
ssignment operations like to&nbsp;<font face=3D"Courier" class=3D"">std::ti=
e</font> in the OP.</div><div class=3D""><br class=3D""></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=_D01DCD90-2953-4100-9334-C1E4B27ABB33--

.
