220 11848 <6ff861ad-4711-48f9-981f-dcd41babf567@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: tomaszkam@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: N4078: Rvalue reference overloads for value()
 method returns object by value
Date: Fri, 11 Jul 2014 02:26:24 -0700 (PDT)
Lines: 125
Approved: news@gmane.org
Message-ID: <6ff861ad-4711-48f9-981f-dcd41babf567@isocpp.org>
References: <b538efba-faf4-4ffc-a553-302b9d2ba2c0@isocpp.org>
 <CANh-dX=M7niArNp-1sCcqxaREEJSxmjMftgw7uMHN9YnZC-h+w@mail.gmail.com>
 <4DA018C3-2327-4F55-B7F8-7988EC7B789A@gmail.com> <1a858a77-310b-4591-aaf5-960c40d9f5fc@isocpp.org>
 <66AF41C1-CB37-4311-98EA-D47DBC6068DC@gmail.com> <66c38b61-7a95-4ace-b34f-2346bb334fb9@isocpp.org>
 <F1CBA358-0AD8-4ADD-99DA-6D00FCFE150F@gmail.com> <CAFk2RUZENmaMW5NwBaiF6byfhgRyPUsSmuyVjnRDhbjcfaTtQA@mail.gmail.com>
 <CC03CC1C-8487-40C8-97DF-2CA7661DAD55@gmail.com> <CAFk2RUa7-WTcL=XFYO8KMyU4rdpjDEfFM6n6SkUZ=SW_U7s5XQ@mail.gmail.com>
 <EF930317-EB97-402E-A3A0-CC46E7E2D998@gmail.com> <CAFk2RUZigiwLwFpfVXuFS8cqy38hPG3OGhGUi+iNwSYuYvyAyQ@mail.gmail.com>
 <A46ADDB4-C9B0-4163-81BE-900CD879D8C8@gmail.com> <CAFk2RUZ-DqEcMeehjH8KedYgErxKMq4O9kmeN4FZzjkXMYSsiw@mail.gmail.com>
 <6F4B3C72-9962-48DC-8527-0C89EA1B9710@gmail.com> <CAFk2RUb5xynaoQx-j4cQuXC8t-0GGc9-CZyRA2V=j6cfuNQV=g@mail.gmail.com>
 <35873CE5-ED8C-4C03-A6A1-E4132DECD91F@gmail.com> <CAFk2RUYRJSNcXykj9oPd=3EehSozf7PcX8ACM_hrqhK+Ur2V8A@mail.gmail.com>
 <335948E6-8140-4673-B958-930356A52070@gmail.com> <CAFk2RUYf+tpBvxiK00O=FncB01BWe6+SXiYBN7fixd4mhm+Z-w@mail.gmail.com>
 <76ACA175-5A44-4BE8-B49F-BAC6DA65E6B1@gmail.com> <CAFk2RUah5k9zy_mQqeNN9mec0PYkmKDZp7LVXm64dTeSLaw6nQ@mail.gmail.com>
 <4D3852AD-1AEB-44BA-941C-D645BAD19405@gmail.com> <6a4b6425-1167-40c1-acd8-3945c8cd4c74@isocpp.org>
 <13DD0D7A-A146-4667-9F30-6FB3739CDBE0@gmail.com> <CADGW59=9uFv-fXRVuBCE+3fdycqTzaqCJnuVmmaT6mOF=1=-MA@mail.gmail.com>
 <E9F36B2C-A142-4B6C-ADFD-57D0E11F2C5B@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_117_13150077.1405070784540"
X-Trace: ger.gmane.org 1405070796 637 80.91.229.3 (11 Jul 2014 09:26:36 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 11 Jul 2014 09:26:36 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDNPVXXG6IGBBQW372OQKGQEBGP6QYQ@isocpp.org Fri Jul 11 11:26:29 2014
Return-path: <std-proposals+bncBDNPVXXG6IGBBQW372OQKGQEBGP6QYQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ie0-f200.google.com ([209.85.223.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDNPVXXG6IGBBQW372OQKGQEBGP6QYQ@isocpp.org>)
	id 1X5X63-0001hz-UC
	for gclcip-std-proposals@m.gmane.org; Fri, 11 Jul 2014 11:26:28 +0200
Original-Received: by mail-ie0-f200.google.com with SMTP id at20sf4271579iec.3
        for <gclcip-std-proposals@m.gmane.org>; Fri, 11 Jul 2014 02:26:27 -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
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=6ap7dmTmxbAZ09ncSp77SvWBWew1yf0SV6H7hIHL0Hc=;
        b=e293Ye5sFt2M1JVz+SyANGmGD8dlJLqGq0TfU7ZPLJaom9guc9cf9GcoOu+70plS5q
         GAt0EvnMEaZHcfkTt4UIXc9ps7Kr1hvWA/BHaPLUKBnCC10zjjGVe6ftVBDnPe2bazEW
         H2SVDGcVynpRdl/p/Gpcbo+2IDdNV5t+uO7H2dFdg2/m0N3CiwisHnLNva5J4jrTuYD/
         X5FpnZw2C3XOUFd1S1pazWk8xv6gLIPlc12YeTpH4dPQGaZYTqA8Vu0d7BHLaALQ5LZo
         rBb8LVPdd7rmjLKRVH6KnI8Yy5DGQtiv2cGfpNIRIL55Kr8ihh1qbz3lajSIKurk/BmA
         3GcQ==
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:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=6ap7dmTmxbAZ09ncSp77SvWBWew1yf0SV6H7hIHL0Hc=;
        b=SewMFeh53l3/lpQKy720cZhKHuvNuvWzCOwx+VwaptcoY/T4aPzNpIaddPL45x1W1s
         wCvLwfM8CzLgJjf0DqVO6v6cLQCya4JW8XDmQ+s53Wnps3il+lnCO3NZEWF4DmWMh2HM
         JGJBmj/AfgsfJLwtsl2iFNGjzXAToZ1IuVA2d/UGLA6XKDBAHu4BuMGkTLtgTNl03Lgi
         CoDXAWhkvhxRWA06T7KH2M7IzIX62ufCurQH7+CSFOiwXKiFnSA0h1babD/4XwUXseA5
         aiYNptZ7eFWDy11h36gHb99uQHnN4dXEEy6IWTMxCfmisttEjjXbNzw/itHItq4+k2mN
         n0JQ==
X-Gm-Message-State: ALoCoQkOGIWpj1T8RtCpc4XZQuhC5ErisXLJjetPmdDlmlw1xssl+d3sN5rd+RlfrDvoxweMAvLo
X-Received: by 10.182.125.4 with SMTP id mm4mr18486711obb.49.1405070786959;
        Fri, 11 Jul 2014 02:26:26 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.49.194 with SMTP id w2ls289530obn.56.gmail; Fri, 11 Jul
 2014 02:26:25 -0700 (PDT)
X-Received: by 10.182.98.136 with SMTP id ei8mr383obb.39.1405070785909;
        Fri, 11 Jul 2014 02:26:25 -0700 (PDT)
In-Reply-To: <E9F36B2C-A142-4B6C-ADFD-57D0E11F2C5B@gmail.com>
X-Original-Sender: tomaszkam@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: <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:11848
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11848>

------=_Part_117_13150077.1405070784540
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

But this still does not work with current overloads, so it wont be broken.=
=20

In addition the auto&& will never work with expression templates even if=20
operator auto/using auto is introduced. If we have a matrix class that uses=
=20
expression templates for multuplication the following
expression m1*m2 will return object by value (mult_result) that stores=20
references so following:
  auto s =3D m1*m2;
  auto&& s =3D m1*m2;
Will not work, becuase the object referenced by mult_result will be=20
destroyed by end of expression. The operator auto fixes only the first case=
..

But actually doing:
with(expr, [](auto&& cs) { /*code that uses it*/ });=20
Will fix every dangling reference.
Or:
auto f =3D []() -> delctype(auto) { return /*some long expr*/l }
somelongexprtakingbeforeresultbrokeninparts(f());
Becuaxse all temporary objects and code that uses it will be run in single=
=20
expression.


W dniu pi=C4=85tek, 11 lipca 2014 11:02:08 UTC+2 u=C5=BCytkownik David Krau=
ss napisa=C5=82:
>
>
> On 2014=E2=80=9307=E2=80=9311, at 4:58 PM, Tomasz Kami=C5=84ski <toma...@=
gmail.com=20
> <javascript:>> wrote:=20
>
> > Could you please provide me actuall code example that is actually broke=
n=20
> by introduction of T&& operator*() && to existing set of overloads? Id di=
d=20
> not found any in your post, only The generic statment tha will broek the=
=20
> library/code.=20
>
> As was discussed earlier, return-by-xvalue does not work with local=20
> universal references. Universal references are not just a cute thing that=
=20
> trendy programmers like to sprinkle around, they provide a way for generi=
c=20
> code to bind a name to something which may or may not be a reference.=20
>
>

--=20

---=20
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 e=
mail 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-proposa=
ls/.

------=_Part_117_13150077.1405070784540
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div><div><div><div><div>But this still d=
oes not work=20
with current overloads, so it wont be broken. <br><br>In addition the auto&=
amp;&amp; will never work with expression templates even if operator auto/u=
sing auto is introduced. If we have a matrix class that uses expression tem=
plates for multuplication the following<br>expression m1*m2 will return obj=
ect by value (mult_result) that stores references so following:<br>&nbsp; a=
uto s =3D m1*m2;<br>&nbsp; auto&amp;&amp; s =3D m1*m2;<br>Will not work, be=
cuase the object referenced by mult_result will be destroyed by end of expr=
ession. The operator auto fixes only the first case.<br><br></div>But actua=
lly doing:<br>
</div>with(expr, [](auto&amp;&amp; cs) { /*code that uses it*/ }); <br></di=
v>Will fix every dangling reference.<br>Or:<br></div>auto f =3D []() -&gt; =
delctype(auto) { return /*some long expr*/l }<br></div>somelongexprtakingbe=
foreresult<wbr>brokeninparts(f());<br>
</div>Becuaxse all temporary objects and code that uses it will be run in s=
ingle expression.<br><br><br>W dniu pi=C4=85tek, 11 lipca 2014 11:02:08 UTC=
+2 u=C5=BCytkownik David Krauss napisa=C5=82:<blockquote class=3D"gmail_quo=
te" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddi=
ng-left: 1ex;">
<br>On 2014=E2=80=9307=E2=80=9311, at 4:58 PM, Tomasz Kami=C5=84ski &lt;<a =
href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"zJOvvgqpbWo=
J" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this.h=
ref=3D'javascript:';return true;">toma...@gmail.com</a>&gt; wrote:
<br>
<br>&gt; Could you please provide me actuall code example that is actually =
broken by introduction of T&amp;&amp; operator*() &amp;&amp; to existing se=
t of overloads? Id did not found any in your post, only The generic statmen=
t tha will broek the library/code.
<br>
<br>As was discussed earlier, return-by-xvalue does not work with local uni=
versal references. Universal references are not just a cute thing that tren=
dy programmers like to sprinkle around, they provide a way for generic code=
 to bind a name to something which may or may not be a reference.
<br>
<br></blockquote></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_117_13150077.1405070784540--

.
