220 11856 <d3b319ce-d2a1-47ae-a874-75059e8c3e56@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:56:24 -0700 (PDT)
Lines: 105
Approved: news@gmane.org
Message-ID: <d3b319ce-d2a1-47ae-a874-75059e8c3e56@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>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_154_13869155.1405072585090"
X-Trace: ger.gmane.org 1405072595 22557 80.91.229.3 (11 Jul 2014 09:56:35 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 11 Jul 2014 09:56:35 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDNPVXXG6IGBBSXJ72OQKGQENKWE5YQ@isocpp.org Fri Jul 11 11:56:27 2014
Return-path: <std-proposals+bncBDNPVXXG6IGBBSXJ72OQKGQENKWE5YQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vc0-f199.google.com ([209.85.220.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDNPVXXG6IGBBSXJ72OQKGQENKWE5YQ@isocpp.org>)
	id 1X5XZ5-0007HB-Gb
	for gclcip-std-proposals@m.gmane.org; Fri, 11 Jul 2014 11:56:27 +0200
Original-Received: by mail-vc0-f199.google.com with SMTP id ij19sf2923931vcb.10
        for <gclcip-std-proposals@m.gmane.org>; Fri, 11 Jul 2014 02:56:26 -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=0Ev7ybJzgnRLQq2Vyhp8ohnxH7aTZw6ghNiuc9TctPM=;
        b=cVK2iSumYAmFsUGjqy9nTtwpeu+B27XrWwFnT6rybRIhYKVvXM82Q1yZqc9jnm/JLh
         8Bczypmnsyo/6IRjScDcibc1SR8kCeGRhyByNdBK94KyQvH12GiTKHQ+Nc9sSRnuGXHv
         FQtcRFYhR0GN8uWwSbmeRy9ogMYFip6MzPPUPJdpbi2sx78/2RxhiQsJC8X1G2oyZhpX
         U1ptBXsaDLNviRx7AWrBRXztwv51S0JbN3PBm2kZGkVFF7JYctDCT7YPBnx1CR9oBBK4
         mtP4gIF5HIv2jiHEDW2mPZxJ4Iyl/XooUJOBRb0+hPRNLYBIJmkmfiPqCgctKQKfYuls
         cj4w==
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=0Ev7ybJzgnRLQq2Vyhp8ohnxH7aTZw6ghNiuc9TctPM=;
        b=ksha4iP4HBQjHFNCfZ9Ssh4PLDAWfrdC1nP8g1NG2mDAuhPZDao2FUpgLvq9wyBj2A
         8q6Ep8rnaZ1ZI9fUpSQdfG1KcaMVtmqXZPCLXIY0ubrXo9bIfJ2xvYCVZ7Hhe0OBZN3v
         rSDZASdWqNlz/ZD8CCu1WIaV4FMn2tIvpB2C87ZQ3XV4a5mKiYow+vVyFxP1gjnA68hx
         Cf831srxo6B31A/CEIg2P69vgdeNHe7FwZFp5fpOjtOy2sh0vKnQiNVUM5tQx8j7AuK9
         /RK3df4QSVl9iUDH2eKk4fayLYJoYQCHnBVZtdxgMmx63B17E0CqBii+5nPIqmDBtXyz
         5MPw==
X-Gm-Message-State: ALoCoQl/K+gzT6subAvOrBg8lHc9vu8uYBX/oVj6Y09iaZK7FyNSfwVxQdsG76FbdKZhBtV6YdDG
X-Received: by 10.58.93.162 with SMTP id cv2mr23407677veb.11.1405072586711;
        Fri, 11 Jul 2014 02:56:26 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.246.199 with SMTP id xy7ls366744obc.83.gmail; Fri, 11 Jul
 2014 02:56:25 -0700 (PDT)
X-Received: by 10.182.143.4 with SMTP id sa4mr1038obb.38.1405072585966;
        Fri, 11 Jul 2014 02:56:25 -0700 (PDT)
In-Reply-To: <7411f096-742f-4e9b-a265-1b05a1af5521@isocpp.org>
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:11856
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11856>

------=_Part_154_13869155.1405072585090
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

And the really funny think. Your code will not work if container_handle is=
=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.

W dniu pi=C4=85tek, 11 lipca 2014 11:49:09 UTC+2 u=C5=BCytkownik toma...@gm=
ail.com=20
napisa=C5=82:
>
> Acutall case does even need susbtitute:
> template< typename container_handle >
> void operate_on_fifth_thing( container_handle && ch ) {
>   process_for_a_long_time( * std::forward< container_handle >( ch ) )[ 5 =
]=20
> );
> }
>
> That willl work with any body:
> template<typename T, typename F>
> void with(T&& t, FV&& fv) { std::forward<FV>(fv)(std::forward<T>(t)); }
>
> template< typename container_handle >
> void operate_on_fifth_thing( container_handle && ch ) {
>     with(( * std::forward< container_handle >( ch ) )[ 5 ], [](auto &&=20
> fifth_thing) {
>       // This is illustrated as a function call, but there might as well=
=20
> be a loop here.
>       process_for_a_long_time( std::forward< decltype( thing ) >(=20
> fifth_thing ) );
>     });
> }
>

--=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_154_13869155.1405072585090
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">And the really funny think. Your code will not work if con=
tainer_handle is a lazy evaluator and <font face=3D"Courier">* std::forward=
&lt; container_handle &gt;( ch ) acutally returns the container by value, o=
rtogonalny to the f</font>act if we have &amp;&amp; overloads and the solut=
ions presented by me will actually fix the code. Because the <font face=3D"=
Courier">* std::forward&lt; container_handle &gt;( ch )</font> will be crea=
ted and used in one expression. The auto&amp;&amp; will create dangling ref=
erence.<br><br>W dniu pi=C4=85tek, 11 lipca 2014 11:49:09 UTC+2 u=C5=BCytko=
wnik toma...@gmail.com napisa=C5=82:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr"><div>Acutall case does even need susbtitute:<br><div=
><font face=3D"Courier">template&lt; typename container_handle &gt;</font><=
/div><div><font face=3D"Courier">void operate_on_fifth_thing( container_han=
dle &amp;&amp; ch ) {</font></div><div><font face=3D"Courier">&nbsp; proces=
s_for_a_long_time( </font><font face=3D"Courier"><font face=3D"Courier">* s=
td::forward&lt; container_handle &gt;( ch ) )[ 5 ]</font> );<br></font></di=
v><div><font face=3D"Courier">}</font></div><br>That willl work with any bo=
dy:<br>template&lt;typename T, typename F&gt;<br>void with(T&amp;&amp; t, F=
V&amp;&amp; fv) { std::forward&lt;FV&gt;(fv)(std::<wbr>forward&lt;T&gt;(t))=
; }<br><br><div><font face=3D"Courier">template&lt; typename container_hand=
le &gt;</font></div><div><font face=3D"Courier">void operate_on_fifth_thing=
( container_handle &amp;&amp; ch ) {<br>&nbsp;&nbsp;&nbsp; with(</font><fon=
t face=3D"Courier">( * std::forward&lt; container_handle &gt;( ch ) )[ 5 ],=
 [](</font><font face=3D"Courier">auto &amp;&amp; fifth_thing) {<br></font>=
</div></div><div><font face=3D"Courier"></font></div><div><font face=3D"Cou=
rier">&nbsp; &nbsp; &nbsp; // This is illustrated as a function call, but t=
here might as well be a loop here.</font></div><div><font face=3D"Courier">=
&nbsp; &nbsp; &nbsp; process_for_a_long_time( std::forward&lt; decltype( th=
ing ) &gt;( fifth_thing ) );<br>&nbsp;&nbsp;&nbsp; });<br></font></div><div=
><font face=3D"Courier">}</font></div></div></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_154_13869155.1405072585090--

.
