220 21344 <ba907914-73e5-4ffb-b6af-7fa630681af1@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: Tue, 6 Oct 2015 04:06:49 -0700 (PDT)
Lines: 173
Approved: news@gmane.org
Message-ID: <ba907914-73e5-4ffb-b6af-7fa630681af1@isocpp.org>
References: <f8a1e157-ae9a-40f8-9bc1-5aff59eefc10@isocpp.org>
 <0a839ad1-1a3c-4323-a20c-3cd910ec08f4@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_35_119634074.1444129609270"
X-Trace: ger.gmane.org 1444129614 21358 80.91.229.3 (6 Oct 2015 11:06:54 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 6 Oct 2015 11:06:54 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCXLLRHD7IDRBSWWZ2YAKGQEH2P5Z5I@isocpp.org Tue Oct 06 13:06:53 2015
Return-path: <std-proposals+bncBCXLLRHD7IDRBSWWZ2YAKGQEH2P5Z5I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pa0-f70.google.com ([209.85.220.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCXLLRHD7IDRBSWWZ2YAKGQEH2P5Z5I@isocpp.org>)
	id 1ZjQ57-0007GI-6I
	for gclcip-std-proposals@m.gmane.org; Tue, 06 Oct 2015 13:06:53 +0200
Original-Received: by pablk4 with SMTP id lk4sf122114616pab.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 06 Oct 2015 04:06:52 -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=Vbcd0IpV5uVxTlzV2goAiUHb0T+ASe0Rqk6+gwvEKUE=;
        b=WWt/rPBnYZmW0EFVPtZCr8+0W7uQmamEnD4+q18tgV0lHMQIV+qjOh/Na9K8MXnS+X
         U4bqV8VnST8Xu0iSPBxa3Pc4l4lOs5Y/8Twgbzf+uvOAqquLbSVPswCOvSRZJezHZvlP
         4TeiBG80QjYfs9QogVaPyd8A/8ap/RLS1DWHwkMLiwp9qMyJdET/CzW3Uelsbf0TNai4
         r9sjw+/EKUGLy1lqyk/2rSuE2RJyTFDNrrpBmXSrGXq4/OMUQ5fcu48+0bwgvkIgofw9
         Fkjf7ff+cmjw1YrGel7R7kQHRJ61xxnKblHCtc0/mItX/gU2soB+clLgjuj0Axy44DSe
         EKjg==
X-Gm-Message-State: ALoCoQnldawdeBK/5odIRdHDks+Cos95ws1Ov2LBoUE03aG3D2C2zMNBhZtma2qz/LxaYVEHyE4T
X-Received: by 10.66.158.229 with SMTP id wx5mr31264088pab.3.1444129611965;
        Tue, 06 Oct 2015 04:06:51 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.160.67 with SMTP id j64ls1961284ioe.3.gmail; Tue, 06 Oct
 2015 04:06:50 -0700 (PDT)
X-Received: by 10.50.79.195 with SMTP id l3mr76371igx.11.1444129610304;
        Tue, 06 Oct 2015 04:06:50 -0700 (PDT)
In-Reply-To: <0a839ad1-1a3c-4323-a20c-3cd910ec08f4@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:21344
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/21344>

------=_Part_35_119634074.1444129609270
Content-Type: multipart/alternative; 
	boundary="----=_Part_36_1099146795.1444129609270"

------=_Part_36_1099146795.1444129609270
Content-Type: text/plain; charset=UTF-8



On Tuesday, October 6, 2015 at 1:56:04 PM UTC+3, Vlad from Moscow wrote:
>
>
> On Monday, October 5, 2015 at 11:24:39 PM UTC+3, Vlad from Moscow wrote:
>>
>> One of methods to convert lvalue to rvalue is to use the functional of 
>> explicit conversion.
>>
>> Compare these two examples
>>
>> //...
>>
>> int main()
>> {
>> {
>>     int a = 10;
>>     int b = 5;
>>     
>>     std::tie( a, b ) = std::minmax( a, b );
>>     std::cout << "a = " << a << ", b = " << b << std::endl;
>> }
>> {
>>     int a = 10;
>>     int b = 5;
>>     
>>     std::tie( a, b ) = std::minmax( int { a }, int { b } );
>>     std::cout << "a = " << a << ", b = " << b << std::endl;
>> }
>> }
>>
>> The out put correspondingly is
>>
>> a = 5, b = 5
>> a = 5, b = 10
>>
>> I am suggesting to use the following general syntax
>>
>>     std::tie( a, b ) = std::minmax( auto( a ), auto( b ) );
>>
>>
> A simplified example that demonstrates the idea
>
> #include <iostream>
>
> void f( int &&x ) { std::cout << "f( int &&( " << x << " ) )\n"; }
> void f( int &x ) { std::cout << "f( int &( " << x << " ) )\n"; }
>
> int main()
> {
>     int x = 3;
>
>     f( x );
>     f( 3 );
> }    
>
> So in the code above I want to substitute the call f( 3 ) for
>
> f( auto( x ) );
>
>  
>

I think that in the preceding example l 

f( auto( 3 ) );

auto( 3 ) should not have any effect.

Or more interesting example

#include <iostream>

void f( int &&x ) { std::cout << "f( int &&( " << x << " ) )\n"; }
void f( int &x ) { std::cout << "f( int &( " << x << " ) )\n"; }

int main()
{
    int x = 3;
    int y = 5;
    
    f( x < y ? x : y );
    f( auto( x < y ? x : y ) );
}  

  
 

-- 

--- 
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_36_1099146795.1444129609270
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><br>On Tuesday, October 6, 2015 at 1:56:04 PM UTC+3, Vlad from Moscow w=
rote:<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>On Monday, October 5, 2015 at 11:24:3=
9 PM 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(20=
4, 204, 204); border-left-width: 1px; border-left-style: solid;"><div dir=
=3D"ltr"><div>One of methods to convert=C2=A0lvalue to rvalue is to use the=
 functional of explicit conversion.</div><div><br></div><div>Compare these =
two examples</div><div><br></div><div>//...</div><div><br></div><div>int ma=
in()<br>{<br>{<br>=C2=A0=C2=A0=C2=A0 int a =3D 10;<br>=C2=A0=C2=A0=C2=A0 in=
t b =3D 5;<br>=C2=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0 std::tie( a, b ) =
=3D std::minmax( a, b );<br>=C2=A0=C2=A0=C2=A0 std::cout &lt;&lt; &quot;a =
=3D &quot; &lt;&lt; a &lt;&lt; &quot;, b =3D &quot; &lt;&lt; b &lt;&lt; std=
::endl;<br>}<br>{<br>=C2=A0=C2=A0=C2=A0 int a =3D 10;<br>=C2=A0=C2=A0=C2=A0=
 int b =3D 5;<br>=C2=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0 std::tie( a, b )=
 =3D std::minmax( int { a }, int { b } );<br>=C2=A0=C2=A0=C2=A0 std::cout &=
lt;&lt; &quot;a =3D &quot; &lt;&lt; a &lt;&lt; &quot;, b =3D &quot; &lt;&lt=
; b &lt;&lt; std::endl;<br>}<br>}</div><div><br></div><div>The out=C2=A0put=
 correspondingly is</div><div><br></div><div>a =3D 5, b =3D 5<br>a =3D 5, b=
 =3D 10</div><div><br></div><div>I am suggesting to use the following gener=
al 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><br></div></div></bl=
ockquote><div><br></div><div>A simplified example that demonstrates the ide=
a</div><div><br></div><div>#include &lt;iostream&gt;</div><div><br></div><d=
iv>void f( int &amp;&amp;x ) { std::cout &lt;&lt; &quot;f( int &amp;&amp;( =
&quot; &lt;&lt; x &lt;&lt; &quot; ) )\n&quot;; }<br>void f(=C2=A0int &amp;x=
 ) { std::cout &lt;&lt; &quot;f(=C2=A0int &amp;( &quot; &lt;&lt; x &lt;&lt;=
 &quot; ) )\n&quot;; }</div><div><br></div><div>int main()<br>{<br>=C2=A0=
=C2=A0=C2=A0 int x =3D 3;<br></div><div><br></div><div>=C2=A0=C2=A0=C2=A0 f=
( x );<br>=C2=A0=C2=A0=C2=A0 f( 3 );<br>}=C2=A0=C2=A0=C2=A0 <br></div><div>=
<br></div><div>So in the code above I want to substitute the call f( 3 ) fo=
r</div><div><br></div><div>f( auto( x ) );</div><div><br></div><div>=C2=A0<=
/div></blockquote><div><br></div><div>I think that in the preceding example=
=C2=A0l=C2=A0</div><div><br></div><div>f( auto( 3 ) );</div><div><br></div>=
<div>auto( 3 ) should not have any effect.</div><div><br></div><div>Or more=
 interesting example</div><div><br></div><div>#include &lt;iostream&gt;</di=
v><div><br></div><div>void f( int &amp;&amp;x ) { std::cout &lt;&lt; &quot;=
f( int &amp;&amp;( &quot; &lt;&lt; x &lt;&lt; &quot; ) )\n&quot;; }<br>void=
 f( int &amp;x ) { std::cout &lt;&lt; &quot;f( int &amp;( &quot; &lt;&lt; x=
 &lt;&lt; &quot; ) )\n&quot;; }</div><div><br></div><div>int main()<br>{<br=
>=C2=A0=C2=A0=C2=A0 int x =3D 3;<br>=C2=A0=C2=A0=C2=A0 int y =3D 5;<br>=C2=
=A0=C2=A0=C2=A0 <br>=C2=A0=C2=A0=C2=A0 f( x &lt; y ? x : y );<br>=C2=A0=C2=
=A0=C2=A0 f( auto( x &lt; y ? x : y ) );<br>}=C2=A0=C2=A0</div><div><br></d=
iv><div>=C2=A0=C2=A0<br>=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_36_1099146795.1444129609270--
------=_Part_35_119634074.1444129609270--

.
