220 11859 <9838a60d-0527-4fb6-907a-acb41732ee19@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 03:25:22 -0700 (PDT)
Lines: 115
Approved: news@gmane.org
Message-ID: <9838a60d-0527-4fb6-907a-acb41732ee19@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> <CAOenAXiBW+BiUkPWdGQHS9fkyEVWJg343NXH9kRSn9owk6FmgQ@mail.gmail.com>
 <DABFDEB7-ADF9-40EC-B4DB-672205A99FEB@gmail.com> <CAFk2RUa-kPWGy29siK4dUu6jbydfwbUeuzCpYOi+b9xc4-msSg@mail.gmail.com>
 <C3BA0F43-683E-4FFE-B04C-9015EB9C7CB0@gmail.com> <7411f096-742f-4e9b-a265-1b05a1af5521@isocpp.org>
 <d3b319ce-d2a1-47ae-a874-75059e8c3e56@isocpp.org>
 <BCB7D3D9-B626-4ACB-8729-F65721FF0109@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_178_3937797.1405074322161"
X-Trace: ger.gmane.org 1405074334 11900 80.91.229.3 (11 Jul 2014 10:25:34 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 11 Jul 2014 10:25:34 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDNPVXXG6IGBBE7X72OQKGQELNJXZKQ@isocpp.org Fri Jul 11 12:25:27 2014
Return-path: <std-proposals+bncBDNPVXXG6IGBBE7X72OQKGQELNJXZKQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f199.google.com ([209.85.214.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDNPVXXG6IGBBE7X72OQKGQELNJXZKQ@isocpp.org>)
	id 1X5Y16-0001wo-Se
	for gclcip-std-proposals@m.gmane.org; Fri, 11 Jul 2014 12:25:25 +0200
Original-Received: by mail-ob0-f199.google.com with SMTP id wn1sf3198183obc.2
        for <gclcip-std-proposals@m.gmane.org>; Fri, 11 Jul 2014 03:25:24 -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=UUvhKo1Y2YniP2R5Zx1zVi+Yqo7WhgUdhzfWnU23nSk=;
        b=HlGEHG28tJstDqurPsN6aVrdd34FsiBrIok4HfuArQY+6mtgvDRhoKswsom32Idirq
         Rl5sGPqdOl2592RKwOki4vN6OjHbUcIV0SWvAGr6mZMtk/lYmKpXbBl9Yqel3yR8Gjjg
         uudgclCVH6gRt2pxLZrWZfDBSwkXbB4nyNR8uXNTuH6XP2OCYsRnrIrVV+ZfjlVcqDNF
         kiX9mpkELenI/Pnb5+ITOlqiBKQ7cH3XFFdP7GzqLzeBREpgjohGR0eyhj8pBXLefIRq
         hrNA89fM3qYEqJt5ZKO6cOUP90Uvdgh2fFJvA/bxGnhFw1wemxy765YyiPEuSJ6JOnI6
         YGoA==
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=UUvhKo1Y2YniP2R5Zx1zVi+Yqo7WhgUdhzfWnU23nSk=;
        b=j6ssUxhMvKaBZdQuk7zTYi8c3XIFAdfcpFEcK0BSUzZ1JHfcVsZydKmnVmQdiWYLmO
         pf156Kj6Y8su405j1GcvX2DCMpTu0zybGVgXzq5pd/IaQVDxuftv+W+aLyTL3gmlIvme
         ytASsPoW+n9QDSSrkf8NhopUT9W9bEOmhcvCVxPEax67HsBKNaB+E6PHzZNKpLMnkk3W
         6wybqzAse6rssc31sc/EnwDc4xgEYQdRZCJRrDA/ky+b4gjkg/l7yP1bYWMw4P94+dJD
         UeNaCNDv+JdRcDpBDVwcoCxlkmTTJ8lKdtjPQ3TgQ1Wr8cnpfd9zQ1/NalYiqfL7V3H0
         +Hbg==
X-Gm-Message-State: ALoCoQk7f8VTetx+99Dreno8rcXeM5YilRCLdIF18khGFJrEBrLEzdBnE5cRoeXGVbGVIwrsHpaY
X-Received: by 10.42.100.138 with SMTP id a10mr1538413ico.32.1405074323887;
        Fri, 11 Jul 2014 03:25:23 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.42.195 with SMTP id q3ls342261obl.97.gmail; Fri, 11 Jul
 2014 03:25:23 -0700 (PDT)
X-Received: by 10.182.153.200 with SMTP id vi8mr10922obb.23.1405074323021;
        Fri, 11 Jul 2014 03:25:23 -0700 (PDT)
In-Reply-To: <BCB7D3D9-B626-4ACB-8729-F65721FF0109@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:11859
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11859>

------=_Part_178_3937797.1405074322161
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



W dniu pi=C4=85tek, 11 lipca 2014 12:17:51 UTC+2 u=C5=BCytkownik David Krau=
ss napisa=C5=82:
>
>
> On 2014=E2=80=9307=E2=80=9311, at 5:56 PM, toma...@gmail.com <javascript:=
> wrote:
>
> And the really funny think. Your code will not work if container_handle i=
s=20
> a lazy evaluator and * std::forward< container_handle >( ch ) acutally=20
> returns the container by value, ortogonalny to the fact if we have &&=20
> overloads and the solutions presented by me will actually fix the code.=
=20
> Because the * std::forward< container_handle >( ch ) will be created and=
=20
> used in one expression. The auto&& will create dangling reference.
>
>
> operator[]() && is also assumed to return a prvalue. This is what gets=20
> bound to the reference, so it does not dangle.
>

But it current design is current state (without && qualifiers) in not work.=
=20
And having && returning by value cause a lot of other problmes (see post=20
above) - especially copying in place wher is is not actually needed. The=20
auto&& f, will still not work if *ch[0] will use an expression template and=
=20
return some operator_result by prvalue that has reference to ch. So if we=
=20
cannot make the auto&& to work in generic code (the generic code should=20
handle expression template), there is no reason to introduce prvalue &&=20
overloads, especially when...

>
> Factoring into a second one-line function completely misses the point.=20
> Sometimes we want multiple lines in a function ;v) .
>
>
... we can use wiht(expr, [](auto&& ) { arbitrally code; }) to make this=20
work everwhere. And yes we can put more than one line in lambda.

--=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_178_3937797.1405074322161
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>W dniu pi=C4=85tek, 11 lipca 2014 12:17:51 UTC+2 u=
=C5=BCytkownik David Krauss napisa=C5=82:<blockquote class=3D"gmail_quote" =
style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-l=
eft: 1ex;"><div style=3D"word-wrap:break-word"><br><div><div>On 2014=E2=80=
=9307=E2=80=9311, at 5:56 PM, <a href=3D"javascript:" target=3D"_blank" gdf=
-obfuscated-mailto=3D"MAw6D2O61Z8J" onmousedown=3D"this.href=3D'javascript:=
';return true;" onclick=3D"this.href=3D'javascript:';return true;">toma...@=
gmail.com</a> wrote:</div><br><blockquote type=3D"cite"><div dir=3D"ltr">An=
d the really funny think. Your code will not work if container_handle is a =
lazy evaluator and <font face=3D"Courier">* std::forward&lt; container_hand=
le &gt;( ch ) acutally returns the container by value, ortogonalny to the f=
</font>act if we have &amp;&amp; overloads and the solutions presented by m=
e will actually fix the code. Because the <font face=3D"Courier">* std::for=
ward&lt; container_handle &gt;( ch )</font> will be created and used in one=
 expression. The auto&amp;&amp; will create dangling reference.<br></div></=
blockquote><div><br></div><div><font face=3D"Courier">operator[]() &amp;&am=
p;</font>&nbsp;is also assumed to return a prvalue. This is what gets bound=
 to the reference, so it does not dangle.</div></div></div></blockquote><di=
v><br>But it current design is current state (without &amp;&amp; qualifiers=
) in not work. And having &amp;&amp; returning by value cause a lot of othe=
r problmes (see post above) - especially copying in place wher is is not ac=
tually needed. The auto&amp;&amp; f, will still not work if *ch[0] will use=
 an expression template and return some operator_result by prvalue that has=
 reference to ch. So if we cannot make the auto&amp;&amp; to work in generi=
c code (the generic code should handle expression template), there is no re=
ason to introduce prvalue &amp;&amp; overloads, especially when...<br></div=
><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bo=
rder-left: 1px #ccc solid;padding-left: 1ex;"><div style=3D"word-wrap:break=
-word"><div><div><br></div><div>Factoring into a second one-line function c=
ompletely misses the point. Sometimes we want multiple lines in a function =
;v) .</div></div><br></div></blockquote><div><br>.. we can use wiht(expr, [=
](auto&amp;&amp; ) { arbitrally code; }) to make this work everwhere. And y=
es we can put more than one line in lambda.<br></div></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_178_3937797.1405074322161--

.
