220 21323 <116a66a2-90ea-4269-ac85-3432ff7094b0@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:37:59 -0700 (PDT)
Lines: 164
Approved: news@gmane.org
Message-ID: <116a66a2-90ea-4269-ac85-3432ff7094b0@isocpp.org>
References: <f8a1e157-ae9a-40f8-9bc1-5aff59eefc10@isocpp.org>
 <31dedac5-7d51-402c-946e-0555c925f70d@isocpp.org>
 <d165db3c-7593-4663-b93e-c37eb8628635@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_3934_1473409605.1444081079692"
X-Trace: ger.gmane.org 1444081084 10776 80.91.229.3 (5 Oct 2015 21:38:04 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 5 Oct 2015 21:38:04 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCXLLRHD7IDRBOG3ZOYAKGQEXPRZNTI@isocpp.org Mon Oct 05 23:38:02 2015
Return-path: <std-proposals+bncBCXLLRHD7IDRBOG3ZOYAKGQEXPRZNTI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ig0-f200.google.com ([209.85.213.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCXLLRHD7IDRBOG3ZOYAKGQEXPRZNTI@isocpp.org>)
	id 1ZjDSM-0005gg-E5
	for gclcip-std-proposals@m.gmane.org; Mon, 05 Oct 2015 23:38:02 +0200
Original-Received: by igbgg5 with SMTP id gg5sf215279113igb.1
        for <gclcip-std-proposals@m.gmane.org>; Mon, 05 Oct 2015 14:38:01 -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=CV0bJ9EIWmgBDgCHJ2aWePxZBdoqvFv3+N7YZyZwTV0=;
        b=CQKj0IUh0Slb5qy7zJ2wN1dbZs5mNeQU82VJx6U5G8q1oguCvDZwhYHmXLO4D65Dp3
         LaVa58ZU5TGFQkJ+vK3kSAzDxVa/7OhDuZ8+qJM0Zpsv9LmhR1qOxtmhjyyO8v+Cx933
         FAYWF/w2fLmOyqL5/JpFIFKGJ59OJC0fFCKSQzwoLDP1U4PctpvTKzwQUy3JGWymcpWv
         pPmuatwNdVAd54us3bm+O4GRWm3lNei2Ew3HhfzgUUfL1oYaVUJ69co+S8515lLc9DGw
         0Y6rHOUM+YaN+NMEVxjWGh09ZAapc/cn8Qlc/k/p+Mj8pSoBAUD+PJql4LyrFWGAAbqV
         RxrQ==
X-Gm-Message-State: ALoCoQncpEo6zuE9bMefdLpqTpxfRP1x1BTb1DppZgPKyosoaB0kI2PkFhYz8awbtZMRUFFh63XU
X-Received: by 10.182.29.40 with SMTP id g8mr28198177obh.27.1444081081618;
        Mon, 05 Oct 2015 14:38:01 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.36.68 with SMTP id k65ls1782810iok.7.gmail; Mon, 05 Oct
 2015 14:38:00 -0700 (PDT)
X-Received: by 10.50.114.135 with SMTP id jg7mr135877igb.8.1444081080753;
        Mon, 05 Oct 2015 14:38:00 -0700 (PDT)
In-Reply-To: <d165db3c-7593-4663-b93e-c37eb8628635@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:21323
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/21323>

------=_Part_3934_1473409605.1444081079692
Content-Type: multipart/alternative; 
	boundary="----=_Part_3935_1237243814.1444081079692"

------=_Part_3935_1237243814.1444081079692
Content-Type: text/plain; charset=UTF-8



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_3935_1237243814.1444081079692
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><br>On Tuesday, October 6, 2015 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-widt=
h: 1px; border-left-style: solid;"><br><br>On Tuesday, October 6, 2015 at 1=
2:12:22 AM UTC+3, Nicol Bolas wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(20=
4, 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 UTC-4, 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-le=
ft-width: 1px; border-left-style: solid;"><div dir=3D"ltr"></div></blockquo=
te><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; pa=
dding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: =
1px; border-left-style: solid;"><div dir=3D"ltr"><div></div><div>I am sugge=
sting 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 re=
sult in a temporary that is copy/move constructed from `a`, with the type h=
aving been deduced from the type of `a` (minus references of course). You w=
ant a shorthand for:<br><br><div style=3D"border: 1px solid rgb(187, 187, 1=
87); border-image: none; background-color: rgb(250, 250, 250);"><code><div>=
<span style=3D"color: rgb(0, 0, 0);">std</span><span style=3D"color: rgb(10=
2, 102, 0);">::</span><span style=3D"color: rgb(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 we=
re trying to store those values in the variables being referenced. Your sol=
ution is to create a pair of temporaries, pass them, and copy the temporari=
es back into your variables.<br><br>Or... you could just create variables. =
You could even use `auto newA =3D a` to create it. And you can use scoping =
to make them temporary:<br><br><div style=3D"border: 1px solid rgb(187, 187=
, 187); border-image: none; background-color: rgb(250, 250, 250);"><code><d=
iv><span style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color: r=
gb(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"col=
or: rgb(102, 102, 0);">=3D</span><span style=3D"color: rgb(0, 0, 0);"> a</s=
pan><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</s=
pan><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);"><br>=C2=A0 std=
</span><span style=3D"color: rgb(102, 102, 0);">::</span><span style=3D"col=
or: rgb(0, 0, 0);">tie</span><span style=3D"color: rgb(102, 102, 0);">(</sp=
an><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, 102, 0);">)</span><span style=3D"color: rgb(0, 0,=
 0);"> </span><span style=3D"color: rgb(102, 102, 0);">=3D</span><span styl=
e=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</span><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: rgb(102, 102, 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=
 language to do? Is it common enough that we need specialized syntax to sol=
ve it?<br><br>Do you have any other use cases for such functionality?<br></=
div></div></blockquote><div><br></div><div><br></div><div>I showed I bad ex=
ample.=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><d=
iv><br></div><div>That is the idea is to do the conversion on the fly witho=
ut using compound expressions.=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_3935_1237243814.1444081079692--
------=_Part_3934_1473409605.1444081079692--

.
