220 21320 <31dedac5-7d51-402c-946e-0555c925f70d@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Conversion from lvalue to rvalue
Date: Mon, 5 Oct 2015 14:12:22 -0700 (PDT)
Lines: 139
Approved: news@gmane.org
Message-ID: <31dedac5-7d51-402c-946e-0555c925f70d@isocpp.org>
References: <f8a1e157-ae9a-40f8-9bc1-5aff59eefc10@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_832_1673001065.1444079542262"
X-Trace: ger.gmane.org 1444079545 15602 80.91.229.3 (5 Oct 2015 21:12:25 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 5 Oct 2015 21:12:25 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBN6PZOYAKGQE6Y7Z2JI@isocpp.org Mon Oct 05 23:12:25 2015
Return-path: <std-proposals+bncBCEKFTV6ZUMBBN6PZOYAKGQE6Y7Z2JI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f197.google.com ([209.85.220.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBN6PZOYAKGQE6Y7Z2JI@isocpp.org>)
	id 1ZjD3Y-0001HL-LO
	for gclcip-std-proposals@m.gmane.org; Mon, 05 Oct 2015 23:12:24 +0200
Original-Received: by qkao72 with SMTP id o72sf238129605qka.2
        for <gclcip-std-proposals@m.gmane.org>; Mon, 05 Oct 2015 14:12:23 -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=9w92VZCZoJWHlWy3XykhaF/9SbEnhiG0r34EE0RHH6E=;
        b=1FFGb2+Dg/vSlJxpEaN07MPuD+kuL4z+RWJsGAhOzvwJT4wgz2Ua0kxp3BXxB5TqJD
         Hu3yp9Ne+hwNOHL5Vho+mbBdEcx3TyslJNeOpX8kPnGLRlLThorEEM4Gwx4IfxZb5UK7
         LscLwAjb61YPbEuo8PTuRh+aagoYY1QccjQR+VZoHNt2ZTUv+cyX9is2WkqqsEisDzJX
         ezuH7OVO6LuSQALyWKRh7gAa6eR7lsfn0058wsnsv/hGBxu7ctVmF3t5GdoFbqKcQwLW
         XyFQIM7A2cFb3xz9BZtgaAF2zQlb/cdZwpJla07XIhF0SGmvfTLa8s5YL8hamvMdhD6w
         lfQQ==
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=9w92VZCZoJWHlWy3XykhaF/9SbEnhiG0r34EE0RHH6E=;
        b=I1bWwJENqXQMBA2fjUEuJz20cATItuC1XrmNMngxtWge1CP9FMOhcxVc8YGRpkfwKM
         7bI9webys5A+P0a/rlTaAUkjzcxVvnGrUR7OXEBAgczJPni/UGUPplX33NlbfEsdEd4F
         LDJlKHVK7+jagd1QqX7rbNecXWLpFyABUkCgjfFXjDQf2VoDmqKsAAlEinD8EERvQ4lB
         SgFaXqcD1wF5/a8r3it7r/zqQCpPTy6Sj24uXDA3hnsBtqSXbvOMiBEx/idGHj0QGASL
         x3PljsVHQBKw6Dn6IYcESHrTxXFfnXWVHgm3MFEqiuY329boPmbhPzkKiywxJeTHxOcM
         jXVQ==
X-Gm-Message-State: ALoCoQlFBwQr6tkYZ6hiXRnMdO1q76F01Ec7+8Veyw52BP/gWSIEgFx3AyDxGgOh9Sq9E8XkuZp6
X-Received: by 10.129.88.87 with SMTP id m84mr27147228ywb.3.1444079543851;
        Mon, 05 Oct 2015 14:12:23 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.5.139 with SMTP id 133ls1049671iof.107.gmail; Mon, 05 Oct
 2015 14:12:23 -0700 (PDT)
X-Received: by 10.50.112.4 with SMTP id im4mr134278igb.1.1444079543043;
        Mon, 05 Oct 2015 14:12:23 -0700 (PDT)
In-Reply-To: <f8a1e157-ae9a-40f8-9bc1-5aff59eefc10@isocpp.org>
X-Original-Sender: jmckesson@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:21320
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/21320>

------=_Part_832_1673001065.1444079542262
Content-Type: multipart/alternative; 
	boundary="----=_Part_833_1477843509.1444079542263"

------=_Part_833_1477843509.1444079542263
Content-Type: text/plain; charset=UTF-8



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?

-- 

--- 
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_833_1477843509.1444079542263
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Monday, October 5, 2015 at 4:24:39 PM UTC-4, Vl=
ad from Moscow wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"></div></blockquote><blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><d=
iv 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 st=
d::minmax(=C2=A0auto( a ),=C2=A0auto( b=C2=A0) );<br></div></div></blockquo=
te><div><br>So you want `auto(a)` to result in a temporary that is copy/mov=
e constructed from `a`, with the type having been deduced from the type of =
`a` (minus references of course). You want a shorthand for:<br><br><div cla=
ss=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-co=
lor: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap:=
 break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">std</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">remove_reference_t</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">decltype</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">a</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)&gt;(</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">a</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">)</span></div></code></div><br>Your basic problem in this case i=
s that fact that the destination function was taking and returning referenc=
es to the parameters, and you were trying to store those values in the vari=
ables being referenced. Your solution is to create a pair of temporaries, p=
ass them, and copy the temporaries back into your variables.<br><br>Or... y=
ou could just create variables. You could even use `auto newA =3D a` to cre=
ate it. And you can use scoping to make them temporary:<br><br><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-colo=
r: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: b=
reak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> oldA </span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> a</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> oldB </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 st=
d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">tie</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> b </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">minmax</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> oldA</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> oldB </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br></span></div></code></div><br>Is this something we really need to modi=
fy the language to do? Is it common enough that we need specialized syntax =
to solve it?<br><br>Do you have any other use cases for such functionality?=
<br></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_833_1477843509.1444079542263--
------=_Part_832_1673001065.1444079542262--

.
