220 21322 <d165db3c-7593-4663-b93e-c37eb8628635@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Vlad from Moscow <vlad.moscow@mail.ru>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Conversion from lvalue to rvalue
Date: Mon, 5 Oct 2015 14:33:15 -0700 (PDT)
Lines: 150
Approved: news@gmane.org
Message-ID: <d165db3c-7593-4663-b93e-c37eb8628635@isocpp.org>
References: <f8a1e157-ae9a-40f8-9bc1-5aff59eefc10@isocpp.org>
 <31dedac5-7d51-402c-946e-0555c925f70d@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2048_845598811.1444080795996"
X-Trace: ger.gmane.org 1444080806 5813 80.91.229.3 (5 Oct 2015 21:33:26 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 5 Oct 2015 21:33:26 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCXLLRHD7IDRBHOZZOYAKGQE3MUFWZI@isocpp.org Mon Oct 05 23:33:21 2015
Return-path: <std-proposals+bncBCXLLRHD7IDRBHOZZOYAKGQE3MUFWZI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f70.google.com ([209.85.218.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCXLLRHD7IDRBHOZZOYAKGQE3MUFWZI@isocpp.org>)
	id 1ZjDNm-0001qJ-TJ
	for gclcip-std-proposals@m.gmane.org; Mon, 05 Oct 2015 23:33:19 +0200
Original-Received: by oiww128 with SMTP id w128sf296668091oiw.0
        for <gclcip-std-proposals@m.gmane.org>; Mon, 05 Oct 2015 14:33:18 -0700 (PDT)
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=J2ZLN4ScDlXX++glfH2OeKlTshKEk/psMsyWyeUjMlE=;
        b=TI5pllSCje/wFJwivzQ8jKE/yLWa0X9KqZbUbuguW/L6/NUVVw2ws9RO04qWPEOBEp
         XAPuyzpEy0YamMNFjAUXJH6wsuvmfOjUhTtYB9Q9G8/yE+OPY1hPOghC6V/ef97Tucgx
         Mfwv6ndtIrejDAm6NaQR21bZ/BEoQurGY4bx/oVbIz1ZXSfnu9NzLLfiFir/78CrmkGk
         pdcT/N07/6dlMsIAk06tZrJtfE6gbG1DKfxlgSQA2ieJioumanhjr1SQsa0B2F9WErBx
         RobzBgv3yQiDGe9cAvfMyzTXMnHZuW0WzESt4OLQYY9eJl2ChivQUCotSPP+t3GrboFq
         RrhA==
X-Gm-Message-State: ALoCoQmP555lOAON8LWbPIrItmcikEUfiWfBHPQplRFHzMRwEUrW+xzN1Yc9iPFTemnVX6+htwa8
X-Received: by 10.50.142.103 with SMTP id rv7mr13095399igb.2.1444080798042;
        Mon, 05 Oct 2015 14:33:18 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.158.79 with SMTP id h76ls209264ioe.104.gmail; Mon, 05 Oct
 2015 14:33:17 -0700 (PDT)
X-Received: by 10.50.142.9 with SMTP id rs9mr135366igb.6.1444080797099;
        Mon, 05 Oct 2015 14:33:17 -0700 (PDT)
In-Reply-To: <31dedac5-7d51-402c-946e-0555c925f70d@isocpp.org>
X-Original-Sender: vlad.moscow@mail.ru
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:21322
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/21322>

------=_Part_2048_845598811.1444080795996
Content-Type: multipart/alternative; 
	boundary="----=_Part_2049_166342910.1444080795997"

------=_Part_2049_166342910.1444080795997
Content-Type: text/plain; charset=UTF-8



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() );  

-- 

--- 
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_2049_166342910.1444080795997
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><br>On Tuesday, October 6, 2015 at 12:12:22 AM UTC+3, Nicol Bolas wrote=
:<blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padd=
ing-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1p=
x; border-left-style: solid;"><div dir=3D"ltr"><br><br>On Monday, October 5=
, 2015 at 4:24:39 PM UTC-4, Vlad from Moscow wrote:<blockquote class=3D"gma=
il_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-lef=
t-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: sol=
id;"><div dir=3D"ltr"></div></blockquote><blockquote class=3D"gmail_quote" =
style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: r=
gb(204, 204, 204); border-left-width: 1px; border-left-style: solid;"><div =
dir=3D"ltr"><div></div><div>I am suggesting to use the following general sy=
ntax</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 c=
onstructed 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 style=
=3D"border: 1px solid rgb(187, 187, 187); border-image: none; -ms-word-wrap=
: break-word; background-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: rgb(0, 0, 0);">remove_reference_t</span><s=
pan 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</spa=
n><span style=3D"color: rgb(102, 102, 0);">)</span></div></code></div><br>Y=
our basic problem in this case is that fact that the destination function w=
as taking and returning references to the parameters, and you were trying t=
o store those values in the variables being referenced. Your solution is to=
 create a pair of temporaries, pass them, and copy the temporaries back int=
o your variables.<br><br>Or... you could just create variables. You could e=
ven use `auto newA =3D a` to create it. And you can use scoping to make the=
m temporary:<br><br><div style=3D"border: 1px solid rgb(187, 187, 187); bor=
der-image: none; -ms-word-wrap: break-word; background-color: rgb(250, 250,=
 250);"><code><div><span style=3D"color: rgb(102, 102, 0);">{</span><span s=
tyle=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><s=
pan style=3D"color: rgb(102, 102, 0);">=3D</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);"> oldB </span><span style=3D"color: rgb(102, =
102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);"> b</span><span sty=
le=3D"color: 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><s=
pan 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 styl=
e=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);"=
> b </span><span style=3D"color: rgb(102, 102, 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><span style=3D"color:=
 rgb(102, 102, 0);">::</span><span style=3D"color: rgb(0, 0, 0);">minmax</s=
pan><span style=3D"color: rgb(102, 102, 0);">(</span><span style=3D"color: =
rgb(0, 0, 0);"> oldA</span><span style=3D"color: rgb(102, 102, 0);">,</span=
><span style=3D"color: rgb(0, 0, 0);"> oldB </span><span style=3D"color: rg=
b(102, 102, 0);">);</span><span style=3D"color: rgb(0, 0, 0);"><br></span><=
span style=3D"color: rgb(102, 102, 0);">}</span><span style=3D"color: rgb(0=
, 0, 0);"><br></span></div></code></div><br>Is this something we really nee=
d to modify the language to do? Is it common enough that we need specialize=
d syntax to solve it?<br><br>Do you have any other use cases for such funct=
ionality?<br></div></div></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>

<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_2049_166342910.1444080795997--
------=_Part_2048_845598811.1444080795996--

.
