220 21333 <42447957-4276-4f59-89b6-ab4be37c47c6@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: "T. C." <rs2740@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Conversion from lvalue to rvalue
Date: Mon, 5 Oct 2015 17:12:57 -0700 (PDT)
Lines: 172
Approved: news@gmane.org
Message-ID: <42447957-4276-4f59-89b6-ab4be37c47c6@isocpp.org>
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>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_0_2130957191.1444090377381"
X-Trace: ger.gmane.org 1444090504 2297 80.91.229.3 (6 Oct 2015 00:15:04 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 6 Oct 2015 00:15:04 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCQ43G7NQIIRBDFEZSYAKGQEVVOJYYY@isocpp.org Tue Oct 06 02:15:04 2015
Return-path: <std-proposals+bncBCQ43G7NQIIRBDFEZSYAKGQEVVOJYYY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yk0-f197.google.com ([209.85.160.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCQ43G7NQIIRBDFEZSYAKGQEVVOJYYY@isocpp.org>)
	id 1ZjFsW-00083W-U2
	for gclcip-std-proposals@m.gmane.org; Tue, 06 Oct 2015 02:13:13 +0200
Original-Received: by ykdz138 with SMTP id z138sf262846831ykd.3
        for <gclcip-std-proposals@m.gmane.org>; Mon, 05 Oct 2015 17:13:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :content-type:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=l1V1yZNxkQWbLIcTIDYP9X/Koi43qnI7UVTNSSurSSs=;
        b=KuNIMh+fiqrCo0NSyPcb/VW9rkACw0SsSXT3E7iLPo/Zbw596JSEU30heXyljKryqm
         4xqB7CNtNZqUkwSSfFf68dlvcc2EzPADd4YgZnAf/cw+gqOxzGiPAsjKWZGX4NCrLFkw
         FuNd9lPwuIDT+6BhUqpZh5A7/8/O0UqImffDdA8OA3/LkQhlx3HZoLBzfWXzSDuDUTya
         r3eZB87xt4Er7G9eaF8GEL5XMp14onf6kb3vAkHM6j8AugK3u7cK4fn6xXRCoIupvlzC
         l6eZNdHKCtzegge5cI0Efpx+iL2DscI3jwf+jsAg+CpNWDaMYZF+4TN5wZ2J3yqhphz9
         RI8g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:content-type:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=l1V1yZNxkQWbLIcTIDYP9X/Koi43qnI7UVTNSSurSSs=;
        b=VKkssNd3MYs6fxgfjMatIfdDeNs7nCZeVLcufcLM5Usomi3JlOXS+cEoFyLcW59VYq
         IbfWCoONZUhGY9/f48OiATR+xyHgeQ43TLyjjMkcKBtGCUQ41tR0z1qg3lujNcsl42JE
         z1wRyvgWxW5iS1U2jw1HZxdg6ZxHO7VirZsZVULcEXwyn8TWMPwEnqEXBposSsVQkgJf
         dg0u6v/tjkMDIaEEmXomh5HIzfrzgey8J6t5EHaBubkKiMwIY5A0mkmiN550Ab5TDBoK
         gUC9X8ZI1+BTXT0nGCF4vEYrB6dFHlE4Fz1zsKlesiNQe6bpief0Xs41cyhc6qslrYjb
         t8zg==
X-Gm-Message-State: ALoCoQlwhN1qU9iH1ej+Rsk3zMW5VsLFHbBin/P5U2aUXCxCxIpS6/EcZoONtKrv6m8wa//R14Ae
X-Received: by 10.13.220.4 with SMTP id f4mr12454520ywe.22.1444090381481;
        Mon, 05 Oct 2015 17:13:01 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.16.166 with SMTP id 38ls1063609ioq.71.gmail; Mon, 05 Oct
 2015 17:13:00 -0700 (PDT)
X-Received: by 10.50.114.36 with SMTP id jd4mr164307igb.6.1444090380475;
        Mon, 05 Oct 2015 17:13:00 -0700 (PDT)
In-Reply-To: <116a66a2-90ea-4269-ac85-3432ff7094b0@isocpp.org>
X-Original-Sender: rs2740@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:21333
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/21333>

------=_Part_0_2130957191.1444090377381
Content-Type: multipart/alternative; 
	boundary="----=_Part_1_1734711264.1444090377389"

------=_Part_1_1734711264.1444090377389
Content-Type: text/plain; charset=UTF-8

http://cplusplus.github.io/EWG/ewg-active.html#188

Although LWG might get to it first with decay_copy.

On Monday, October 5, 2015 at 5:38:00 PM UTC-4, Vlad from Moscow wrote:
>
>
>
> On Tuesday, October 6, 2015 at 12:33:16 AM UTC+3, Vlad from Moscow wrote:
>>
>>
>>
>> On Tuesday, October 6, 2015 at 12:12:22 AM UTC+3, Nicol Bolas wrote:
>>>
>>>
>>>
>>> On Monday, October 5, 2015 at 4:24:39 PM UTC-4, Vlad from Moscow wrote:
>>>>
>>>> I am suggesting to use the following general syntax
>>>>
>>>>     std::tie( a, b ) = std::minmax( auto( a ), auto( b ) );
>>>>
>>>
>>> So you want `auto(a)` to result in a temporary that is copy/move 
>>> constructed from `a`, with the type having been deduced from the type of 
>>> `a` (minus references of course). You want a shorthand for:
>>>
>>> std::remove_reference_t<decltype(a)>(a)
>>>
>>> Your basic problem in this case is that fact that the destination 
>>> function was taking and returning references to the parameters, and you 
>>> were trying to store those values in the variables being referenced. Your 
>>> solution is to create a pair of temporaries, pass them, and copy the 
>>> temporaries back into your variables.
>>>
>>> Or... you could just create variables. You could even use `auto newA = 
>>> a` to create it. And you can use scoping to make them temporary:
>>>
>>> {
>>>   auto oldA = a, oldB = b;
>>>   std::tie( a, b ) = std::minmax( oldA, oldB );
>>> }
>>>
>>> Is this something we really need to modify the language to do? Is it 
>>> common enough that we need specialized syntax to solve it?
>>>
>>> Do you have any other use cases for such functionality?
>>>
>>
>>
>> I showed I bad example. I wanted to demonstrate just the idea.
>>
>> Here is a correct example 
>>
>>     std::vector<int> v = { 1, 2, 3, 7, 1, 5, 4 }; 
>>   
>>     v.erase( std::remove( v.begin(), v.end(), auto( v[0] ) ), v.end() );  
>>
>
>
> That is the idea is to do the conversion on the fly without using compound 
> expressions. 
>

-- 

--- 
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 email 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-proposals/.

------=_Part_1_1734711264.1444090377389
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">http://cplusplus.github.io/EWG/ewg-active.html#188<div><br=
></div><div>Although LWG might get to it first with decay_copy.<br><div><br=
>On Monday, October 5, 2015 at 5:38:00 PM UTC-4, Vlad from Moscow wrote:<bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border=
-left: 1px #ccc solid;padding-left: 1ex;"><br><br>On Tuesday, October 6, 20=
15 at 12:33:16 AM UTC+3, Vlad from Moscow wrote:<blockquote class=3D"gmail_=
quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color=
:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><br><br>On=
 Tuesday, October 6, 2015 at 12:12:22 AM UTC+3, Nicol Bolas wrote:<blockquo=
te class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-left:1ex=
;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style=
:solid"><div dir=3D"ltr"><br><br>On Monday, October 5, 2015 at 4:24:39 PM U=
TC-4, Vlad from Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"mar=
gin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);b=
order-left-width:1px;border-left-style:solid"><div dir=3D"ltr"></div></bloc=
kquote><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;=
padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;b=
order-left-style:solid"><div dir=3D"ltr"><div></div><div>I am suggesting to=
 use the following general syntax</div><div><br></div><div>=C2=A0=C2=A0=C2=
=A0 std::tie( a, b ) =3D std::minmax(=C2=A0auto( a ),=C2=A0auto( b=C2=A0) )=
;<br></div></div></blockquote><div><br>So you want `auto(a)` to result in a=
 temporary that is copy/move constructed from `a`, with the type having bee=
n deduced from the type of `a` (minus references of course). You want a sho=
rthand for:<br><br><div style=3D"border:1px solid rgb(187,187,187);backgrou=
nd-color:rgb(250,250,250)"><code><div><span style=3D"color:rgb(0,0,0)">std<=
/span><span style=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rg=
b(0,0,0)">remove_reference_t</span><span style=3D"color:rgb(102,102,0)">&lt=
;</span><span style=3D"color:rgb(0,0,136)">declty<wbr>pe</span><span style=
=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">a</span>=
<span style=3D"color:rgb(102,102,0)">)&gt;(</span><span style=3D"color:rgb(=
0,0,0)">a</span><span style=3D"color:rgb(102,102,0)">)</span></div></code><=
/div><br>Your basic problem in this case is that fact that the destination =
function was taking and returning references to the parameters, and you wer=
e trying to store those values in the variables being referenced. Your solu=
tion is to create a pair of temporaries, pass them, and copy the temporarie=
s back into your variables.<br><br>Or... you could just create variables. Y=
ou could even use `auto newA =3D a` to create it. And you can use scoping t=
o make them temporary:<br><br><div style=3D"border:1px solid rgb(187,187,18=
7);background-color:rgb(250,250,250)"><code><div><span style=3D"color:rgb(1=
02,102,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 </span><span=
 style=3D"color:rgb(0,0,136)">auto</span><span style=3D"color:rgb(0,0,0)"> =
oldA </span><span style=3D"color:rgb(102,102,0)">=3D</span><span style=3D"c=
olor:rgb(0,0,0)"> a</span><span style=3D"color:rgb(102,102,0)">,</span><spa=
n style=3D"color:rgb(0,0,0)"> oldB </span><span style=3D"color:rgb(102,102,=
0)">=3D</span><span style=3D"color:rgb(0,0,0)"> b</span><span style=3D"colo=
r:rgb(102,102,0)">;</span><span style=3D"color:rgb(0,0,0)"><br>=C2=A0 std</=
span><span style=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rgb=
(0,0,0)">tie</span><span style=3D"color:rgb(102,102,0)">(</span><span style=
=3D"color:rgb(0,0,0)"> a</span><span style=3D"color:rgb(102,102,0)">,</span=
><span style=3D"color:rgb(0,0,0)"> b </span><span style=3D"color:rgb(102,10=
2,0)">)</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color=
:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(0,0,0)"> std</span><spa=
n style=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rgb(0,0,0)">=
minmax</span><span style=3D"color:rgb(102,102,0)">(</span><span style=3D"co=
lor:rgb(0,0,0)"> oldA</span><span style=3D"color:rgb(102,102,0)">,</span><s=
pan style=3D"color:rgb(0,0,0)"> oldB </span><span style=3D"color:rgb(102,10=
2,0)">);</span><span style=3D"color:rgb(0,0,0)"><br></span><span style=3D"c=
olor:rgb(102,102,0)">}</span><span style=3D"color:rgb(0,0,0)"><br></span></=
div></code></div><br>Is this something we really need to modify the languag=
e to do? Is it common enough that we need specialized syntax to solve it?<b=
r><br>Do you have any other use cases for such functionality?<br></div></di=
v></blockquote><div><br></div><div><br></div><div>I showed I bad example.=
=C2=A0I wanted to demonstrate just the idea.</div><div><br></div><div>Here =
is=C2=A0a correct example </div><div><br></div><div>=C2=A0=C2=A0=C2=A0 std:=
:vector&lt;int&gt; v =3D { 1, 2, 3, 7, 1, 5, 4 };=C2=A0<br>=C2=A0=C2=A0<br>=
=C2=A0=C2=A0=C2=A0 v.erase( std::remove( v.begin(), v.end(), auto( v[0] )=
=C2=A0), v.end() );=C2=A0=C2=A0</div></blockquote><div><br></div><div><br><=
/div><div>That is the idea is to do the conversion on the fly without using=
 compound expressions.=C2=A0</div></blockquote></div></div></div>

<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 />

------=_Part_1_1734711264.1444090377389--
------=_Part_0_2130957191.1444090377381--

.
