220 11782 <CAFk2RUYEdZn6t72-ajwY2z4PVLN_wQc12EMX3ycVS12p6+QYxA@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: N4078: Rvalue reference overloads for value()
 method returns object by value
Date: Thu, 10 Jul 2014 09:17:16 +0300
Lines: 55
Approved: news@gmane.org
Message-ID: <CAFk2RUYEdZn6t72-ajwY2z4PVLN_wQc12EMX3ycVS12p6+QYxA@mail.gmail.com>
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: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1404973044 23672 80.91.229.3 (10 Jul 2014 06:17:24 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 10 Jul 2014 06:17:24 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC5JHI7A7ALRB3G77COQKGQEWS2XWHQ@isocpp.org Thu Jul 10 08:17:18 2014
Return-path: <std-proposals+bncBC5JHI7A7ALRB3G77COQKGQEWS2XWHQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qg0-f70.google.com ([209.85.192.70])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC5JHI7A7ALRB3G77COQKGQEWS2XWHQ@isocpp.org>)
	id 1X57fS-0007ZJ-14
	for gclcip-std-proposals@m.gmane.org; Thu, 10 Jul 2014 08:17:18 +0200
Original-Received: by mail-qg0-f70.google.com with SMTP id z60sf19583952qgd.5
        for <gclcip-std-proposals@m.gmane.org>; Wed, 09 Jul 2014 23:17:17 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state: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:content-transfer-encoding;
        bh=p+1Sji5ILxDUiiqELHoeUUii6/yt1dw5bGTzY5HsL+Q=;
        b=jTPNICC96+AnWaBgkTLuFIa8djgtxec+wZ5D1G5w+9WgIATL6hgAtpsNE9cCcbEiyU
         ZIeQuLeXQ2qetEa6RNqZaT/pKcrYryfmFfQEpI6rgPGSdvBCODTpQc1ZIGgF0hDME6DK
         Ccpk0ZmUM7MGgLa08ASZKqtacE/y5wZ343MVt/t3eGUA3aHT0WKcaPnzJy0K/aUacmY3
         ciBWHprySHBgwetnC/iCfj+PBm0cH45KTDbLiERGkczeDh+76okk0SGX+R5PX+Hb8+ij
         +G/vh4HYPUGMRSXaclcB8sIgecBlDxoKPUQkOsOV4Y9bkK4yrh2kfRP1OJOvX6GFGhJx
         De6Q==
X-Gm-Message-State: ALoCoQnnk/GVKcgQPu14w6gNXR2cyk6MuWww0VepnRcM/hE/JlslYN4AsiORBn2pgScMN9FvqgD2
X-Received: by 10.236.151.74 with SMTP id a50mr19732740yhk.32.1404973037262;
        Wed, 09 Jul 2014 23:17:17 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.36.229 with SMTP id p92ls2695362qgp.92.gmail; Wed, 09 Jul
 2014 23:17:16 -0700 (PDT)
X-Received: by 10.140.97.53 with SMTP id l50mr71297417qge.29.1404973036753;
        Wed, 09 Jul 2014 23:17:16 -0700 (PDT)
Original-Received: from mail-qg0-x229.google.com (mail-qg0-x229.google.com [2607:f8b0:400d:c04::229])
        by mx.google.com with ESMTPS id h11si42154731qgf.82.2014.07.09.23.17.16
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Wed, 09 Jul 2014 23:17:16 -0700 (PDT)
Received-SPF: pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:400d:c04::229 as permitted sender) client-ip=2607:f8b0:400d:c04::229;
Original-Received: by mail-qg0-f41.google.com with SMTP id i50so7257799qgf.14
        for <std-proposals@isocpp.org>; Wed, 09 Jul 2014 23:17:16 -0700 (PDT)
X-Received: by 10.224.163.146 with SMTP id a18mr76946721qay.31.1404973036640;
 Wed, 09 Jul 2014 23:17:16 -0700 (PDT)
Original-Received: by 10.224.31.137 with HTTP; Wed, 9 Jul 2014 23:17:16 -0700 (PDT)
In-Reply-To: <F80F564C-1208-4A65-AA1F-382144A3D16A@gmail.com>
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 2607:f8b0:400d:c04::229 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:11782
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11782>

On 10 July 2014 09:12, David Krauss <potswa@gmail.com> wrote:
>
> On 2014=E2=80=9307=E2=80=9310, at 2:04 PM, Ville Voutilainen <ville.vouti=
lainen@gmail.com>
> wrote:
>
> As a very general policy in C++ library design, every accessor to a stric=
tly
> 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.
> Therefore the resource will be going away very soon. It would be incorrec=
t
> to return a reference to it.

There's two examples in this thread which explain why it's quite correct
in order to avoid extraneous temporaries and to allow forwarding to work
without metaprogramming tricks.

> Returning by rvalue reference may be tempting, but that is the semantic o=
f
> move(). It does not transfer ownership, it only provides the caller with =
a
> handle to accept ownership. Returning an rvalue reference is something on=
ly
> special functions should do.

I have no idea where this guideline popped out of.

> Then perhaps we need more cases for copy elision. Sneaky rvalue reference
> hacks will only provide surprises and make user code more brittle. If the=
re
> must be an rvalue reference overload, it should be named move_value() to
> indicate the different semantic.


That would be equally detrimental to users who want to forward.

--=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/.

.
