220 6845 <CAFk2RUY8U8YmChiNH5HzCnBkQycLvyrR0nHgTzMhX-Y9SzQs+A@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Ville Voutilainen <ville.voutilainen@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: auto with copy in expression
Date: Tue, 1 Oct 2013 18:23:41 +0300
Lines: 105
Approved: news@gmane.org
Message-ID: <CAFk2RUY8U8YmChiNH5HzCnBkQycLvyrR0nHgTzMhX-Y9SzQs+A@mail.gmail.com>
References: <65473e60-c6ee-48e4-ae03-fcbe251d7b9d@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a11c22634a5a7dc04e7af8951
X-Trace: ger.gmane.org 1380641022 21597 80.91.229.3 (1 Oct 2013 15:23:42 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 1 Oct 2013 15:23:42 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC5JHI7A7ALRB7WRVOJAKGQEAW5764A@isocpp.org Tue Oct 01 17:23:45 2013
Return-path: <std-proposals+bncBC5JHI7A7ALRB7WRVOJAKGQEAW5764A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-bk0-f69.google.com ([209.85.214.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC5JHI7A7ALRB7WRVOJAKGQEAW5764A@isocpp.org>)
	id 1VR1nd-0001oq-2f
	for gclcip-std-proposals@m.gmane.org; Tue, 01 Oct 2013 17:23:45 +0200
Original-Received: by mail-bk0-f69.google.com with SMTP id na10sf8761108bkb.0
        for <gclcip-std-proposals@m.gmane.org>; Tue, 01 Oct 2013 08:23:44 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=DPbaU1EgCSnmx9/1IebPpzC4stoHI/KZaReHKq20tfg=;
        b=Roy7y4eheLR2EmC9GdBYDIzJD7y61ND9bVNrDR+AE4pkr/XdYvWURJdbiO3P6Mkuu4
         z1waD1llDn9PIPa7Ja34bVny9XdlMTpvFSsKLWt6De1WDcC2KIu36pMJ3r8X2y/4EzYY
         kX5I6TF+EqlXci8+6NoK67mJbin4EaqEE5JtP9zX9ec7SgiSNM295ykK8lvf1M1PgkLj
         bx73/25EYFcY9o40MuDULIiOFo+fOe+H7xYodI1QwhNuVP+8LvpppI8T3Ojxrq5A4cxg
         aaif2doRS+MWSHB6WiisIDR7EcJ75Q3/g8iKfXpdAwRKtwB5dVB0UcsdAq1D1Uufsoif
         rdaA==
X-Received: by 10.180.21.137 with SMTP id v9mr10439315wie.7.1380641024103;
        Tue, 01 Oct 2013 08:23:44 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.84.71 with SMTP id w7ls878553wiy.28.canary; Tue, 01 Oct
 2013 08:23:41 -0700 (PDT)
X-Received: by 10.194.94.101 with SMTP id db5mr1620183wjb.67.1380641021557;
        Tue, 01 Oct 2013 08:23:41 -0700 (PDT)
Original-Received: from mail-wg0-x22f.google.com (mail-wg0-x22f.google.com [2a00:1450:400c:c00::22f])
        by mx.google.com with ESMTPS id bf10si2568889wjc.69.1969.12.31.16.00.00
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Tue, 01 Oct 2013 08:23:41 -0700 (PDT)
Received-SPF: pass (google.com: domain of ville.voutilainen@gmail.com designates 2a00:1450:400c:c00::22f as permitted sender) client-ip=2a00:1450:400c:c00::22f;
Original-Received: by mail-wg0-f47.google.com with SMTP id f12so7332949wgh.2
        for <std-proposals@isocpp.org>; Tue, 01 Oct 2013 08:23:41 -0700 (PDT)
X-Received: by 10.180.9.203 with SMTP id c11mr19072354wib.64.1380641021466;
 Tue, 01 Oct 2013 08:23:41 -0700 (PDT)
Original-Received: by 10.194.42.70 with HTTP; Tue, 1 Oct 2013 08:23:41 -0700 (PDT)
In-Reply-To: <65473e60-c6ee-48e4-ae03-fcbe251d7b9d@isocpp.org>
X-Original-Sender: ville.voutilainen@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of ville.voutilainen@gmail.com designates 2a00:1450:400c:c00::22f as
 permitted sender) smtp.mail=ville.voutilainen@gmail.com;       dkim=pass
 header.i=@gmail.com;       dmarc=pass (p=NONE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:6845
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/6845>

--001a11c22634a5a7dc04e7af8951
Content-Type: text/plain; charset=ISO-8859-1

On 24 September 2013 15:35, Michael AV <donnerdose@googlemail.com> wrote:

> Hi,
>
> I would like to create a copy of the return value of a function. This
> result shall be passed to another function. The two-line solution would be:
>
> auto result = foo();
> bar(result);
>
> bar expects a reference and foo returns a reference. However, in this case
> it is crucial for bar to only receive a copy because (for this specific
> result argument), bar changes what foo delivers. That does not mean,
> however, that bar does always change it's argument.
>
> So, basically I just need a copy and would like to use it within an
> expression. The most intuitive syntax for me would be:
>
> bar(auto(foo()));
>
> which does not work at the moment (as tested with the - clearly obsolete -
> VS2010).
>
> I tried searching this group and thinking about why this syntax does not
> make sense but did not come to any result.
>
> What do you think?
>
>
>
bar([](){auto x(foo()); return x;}());

You can't create temporaries with auto, as far as I understand the language
rules.
Also, in whichever way this temporary is created, bar() needs to accept an
rvalue
reference, since lvalue references can't bind to temporaries.

-- 

--- 
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/.

--001a11c22634a5a7dc04e7af8951
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On 24 September 2013 15:35, Michael AV <span dir=3D"ltr">&lt;<a hre=
f=3D"mailto:donnerdose@googlemail.com" target=3D"_blank">donnerdose@googlem=
ail.com</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div>Hi,</div><div><br></di=
v><div>I would like to create a copy of the return value of a function. Thi=
s result shall be passed to another function. The two-line solution would b=
e:</div>
<div><br></div><div><div style=3D"background-color:rgb(250,250,250);border:=
1px solid rgb(187,187,187);word-wrap:break-word"><code><div><div style=3D"b=
ackground-color:rgb(250,250,250);border:1px solid rgb(187,187,187);word-wra=
p:break-word">
<code><div><font color=3D"#660066">auto result =3D foo();<br>bar(result);</=
font></div></code></div></div></code></div><br>bar expects a reference and =
foo returns a reference. However, in this case it is crucial for bar to onl=
y receive a copy because (for this specific result argument), bar changes w=
hat foo delivers. That does not mean, however, that bar does always change =
it&#39;s argument.</div>
<div><br></div><div>So, basically I just need a copy and would like to use =
it within an expression. The most intuitive syntax for me would be:</div><d=
iv><br></div><div><div style=3D"background-color:rgb(250,250,250);border:1p=
x solid rgb(187,187,187);word-wrap:break-word">
<code><div><font color=3D"#660066">bar(auto(foo()));</font></div></code></d=
iv><br>which does not work at the moment (as tested with the - clearly obso=
lete - VS2010).</div><div><br></div><div>I tried searching this group and t=
hinking about why this syntax does not make sense but did not come to any r=
esult.</div>
<div><br></div><div>What do you think?</div><div><br><br></div></div></bloc=
kquote><div><br></div><div>bar([](){auto x(foo()); return x;}()); <br></div=
></div><br></div><div class=3D"gmail_extra">You can&#39;t create temporarie=
s with auto, as far as I understand the language rules.<br>
</div><div class=3D"gmail_extra">Also, in whichever way this temporary is c=
reated, bar() needs to accept an rvalue<br>reference, since lvalue referenc=
es can&#39;t bind to temporaries.<br></div></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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 />

--001a11c22634a5a7dc04e7af8951--

.
