220 11783 <8888e3af-c11a-4e44-970d-01c0ef795f97@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: Wed, 9 Jul 2014 23:18:42 -0700 (PDT)
Lines: 139
Approved: news@gmane.org
Message-ID: <8888e3af-c11a-4e44-970d-01c0ef795f97@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> <CAFk2RUa5foB0ySVSjfc3t6cBOWE-+Qt76jnRv3X=FHP6ntpPjw@mail.gmail.com>
 <F80F564C-1208-4A65-AA1F-382144A3D16A@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_31_922469.1404973122432"
X-Trace: ger.gmane.org 1404973135 24836 80.91.229.3 (10 Jul 2014 06:18:55 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 10 Jul 2014 06:18:55 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDNPVXXG6IGBBQ7A7COQKGQEAZZVO6I@isocpp.org Thu Jul 10 08:18:49 2014
Return-path: <std-proposals+bncBDNPVXXG6IGBBQ7A7COQKGQEAZZVO6I@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+bncBDNPVXXG6IGBBQ7A7COQKGQEAZZVO6I@isocpp.org>)
	id 1X57gr-0000II-8F
	for gclcip-std-proposals@m.gmane.org; Thu, 10 Jul 2014 08:18:45 +0200
Original-Received: by mail-pa0-f70.google.com with SMTP id lj1sf57168065pab.1
        for <gclcip-std-proposals@m.gmane.org>; Wed, 09 Jul 2014 23:18:44 -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=8WnHFw+ZwqQbOWBrHQSXB/CUWrvSviGLwqMvyvaOwwQ=;
        b=HdF2Wrym3vJFis1a9nUEaHEMlOiz+okrKexWjVWZI+Z79HXRfrAIbSGgSw1xbDWv5p
         5N6pMUXIm3XTHcuHQj26kzOMYZh6TiMd8J+MY66g/WqUGTJC4gGazzLVlTRc2WV5pdLz
         ThbwuNrfkM/4Pq6A0GsdtYF+w4/S2Aiy55vBBst3Pyoh1lArpPD544eR/CLHpgDwe2iJ
         AfTHhLF/sCFja//QmgEBID36GaBoCG5KHr27InC32unids+Q9nHnXVOTbkp36vhsE4me
         xaDfv+qhcJ9R4dwQVZcsLltvqbnve4bXXiRMZBnzE+2eK2uS3RSE2vqFoS8rshcyu++V
         Bljw==
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=8WnHFw+ZwqQbOWBrHQSXB/CUWrvSviGLwqMvyvaOwwQ=;
        b=b2M5N7xvaIdvHXDswOKkGIWcgc7AxKmd5r0WJLuiczfCqg7LrbELOAx4T0Xx9lAwrC
         xhHt1grPEbCbh4JR2NMymWrjM0yPO2eO+RskwWzqgsDCiZ+bEGCwXntY4h5LQtWrXZj0
         AvWAnDsB2bf71sgr5xIzx8z55UfdE7qA1Yagj4AivTeqQiDPjtTfAz5cMoRTGF+7OgIa
         OPwkQS/oexMFqEtHDn+na75NpgXtW4I3dlSVQ///KonOztEPeWrw6c5zDp4REJ+3QruS
         o5Y9YzSm5JQfn7FCDaT/SETCILsLNT0j+c8qxXPkW3Cs306eLF6burRH35hNe94VW9Yo
         XNaA==
X-Gm-Message-State: ALoCoQk2dWCbbHGheiw0np5f/kq7GNhwBcY85tcmsPOMdH1xGTK7gg4w/WQilX31K/HTA8OUiRdA
X-Received: by 10.66.182.130 with SMTP id ee2mr8096519pac.37.1404973124198;
        Wed, 09 Jul 2014 23:18:44 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.135.193 with SMTP id pu1ls1436030obb.19.gmail; Wed, 09 Jul
 2014 23:18:42 -0700 (PDT)
X-Received: by 10.182.196.34 with SMTP id ij2mr4937obc.24.1404973122957;
        Wed, 09 Jul 2014 23:18:42 -0700 (PDT)
In-Reply-To: <F80F564C-1208-4A65-AA1F-382144A3D16A@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: <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:11783
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11783>

------=_Part_31_922469.1404973122432
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



W dniu czwartek, 10 lipca 2014 08:12:55 UTC+2 u=C5=BCytkownik David Krauss=
=20
napisa=C5=82:
>
>
> On 2014=E2=80=9307=E2=80=9310, at 2:04 PM, Ville Voutilainen <ville.vo...=
@gmail.com=20
> <javascript:>> wrote:
>
> As a very general policy in C++ library design, every accessor to a=20
> strictly
> owned resource should be lvalue-qualified and/or return by value. This be=
st
> practice should be applied across the standard library.
>
>
> I fail to see how that is "best practice=E2=80=9D.
>
>
> The resource is strictly owned and the owner is represented by an xvalue.=
=20
> Therefore the resource will be going away very soon. It would be incorrec=
t=20
> to return a reference to it.
>
> Returning by rvalue reference may be tempting, but that is the semantic o=
f=20
> move(). It does not transfer ownership, it only provides the caller with =
a=20
> handle to accept ownership. Returning an rvalue reference is something on=
ly=20
> special functions should do.
>
> Whether returning a direct member or something owned elsewhere, methods o=
f
> an xvalue should always return by value. If a temporary might be introduc=
ed
> elsewhere, correctness is always worth the cost =E2=80=94 and copy elisio=
n will
> probably eliminate it anyway.
>
>
> Except that copy elision will not eliminate it, and this correctness
> is not worth
> the cost.
>
>
> Then perhaps we need more cases for copy elision. Sneaky rvalue reference=
=20
> hacks will only provide surprises and make user code more brittle. If the=
re=20
> must be an rvalue reference overload, it should be named move_value() to=
=20
> indicate the different semantic.
>
>
I dont see like introduing the rvalue reference overload that makes the=20
code works more coherent with current status qou, that is no reference=20
overlaod for getters provide more suprises that introducing temporaries in=
=20
places that they were not present before in existing codebases. Please also=
=20
remeber about forward.=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_31_922469.1404973122432
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>W dniu czwartek, 10 lipca 2014 08:12:55 UTC+2 u=C5=
=BCytkownik David Krauss napisa=C5=82:<blockquote class=3D"gmail_quote" sty=
le=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left=
: 1ex;"><div style=3D"word-wrap:break-word"><br><div><div>On 2014=E2=80=930=
7=E2=80=9310, at 2:04 PM, Ville Voutilainen &lt;<a href=3D"javascript:" tar=
get=3D"_blank" gdf-obfuscated-mailto=3D"rszrJvo-vZ0J" onmousedown=3D"this.h=
ref=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';retu=
rn true;">ville.vo...@gmail.com</a>&gt; wrote:</div><br><blockquote type=3D=
"cite"><blockquote type=3D"cite">As a very general policy in C++ library de=
sign, every accessor to a strictly<br>owned resource should be lvalue-quali=
fied and/or return by value. This best<br>practice should be applied across=
 the standard library.<br></blockquote><br>I fail to see how that is "best =
practice=E2=80=9D.<br></blockquote><div><br></div><div>The resource is stri=
ctly owned and the owner is represented by an xvalue. Therefore the resourc=
e will be going away very soon. It would be incorrect to return a reference=
 to it.</div><div><br></div><div>Returning by rvalue reference may be tempt=
ing, but that is the semantic of move(). It does not transfer ownership, it=
 only provides the caller with a handle to accept ownership. Returning an r=
value reference is something only special functions should do.</div><br><bl=
ockquote type=3D"cite"><blockquote type=3D"cite">Whether returning a direct=
 member or something owned elsewhere, methods of<br>an xvalue should always=
 return by value. If a temporary might be introduced<br>elsewhere, correctn=
ess is always worth the cost =E2=80=94 and copy elision will<br>probably el=
iminate it anyway.<br></blockquote><br>Except that copy elision will not el=
iminate it, and this correctness<br>is not worth<br>the cost.<br></blockquo=
te></div><br><div>Then perhaps we need more cases for copy elision. Sneaky =
rvalue reference hacks will only provide surprises and make user code more =
brittle. If there must be an rvalue reference overload, it should be named =
<font face=3D"Courier">move_value()</font> to indicate the different semant=
ic.</div><div><br></div></div></blockquote><div><br>I dont see like introdu=
ing the rvalue reference overload that makes the code works more coherent w=
ith current status qou, that is no reference overlaod for getters provide m=
ore suprises that introducing temporaries in places that they were not pres=
ent before in existing codebases. Please also remeber about forward. <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_31_922469.1404973122432--

.
