220 11779 <CAFk2RUa5foB0ySVSjfc3t6cBOWE-+Qt76jnRv3X=FHP6ntpPjw@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:04:19 +0300
Lines: 58
Approved: news@gmane.org
Message-ID: <CAFk2RUa5foB0ySVSjfc3t6cBOWE-+Qt76jnRv3X=FHP6ntpPjw@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>
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 1404972270 15833 80.91.229.3 (10 Jul 2014 06:04:30 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 10 Jul 2014 06:04:30 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC5JHI7A7ALRBY6Z7COQKGQECREIIUQ@isocpp.org Thu Jul 10 08:04:24 2014
Return-path: <std-proposals+bncBC5JHI7A7ALRBY6Z7COQKGQECREIIUQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qg0-f71.google.com ([209.85.192.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC5JHI7A7ALRBY6Z7COQKGQECREIIUQ@isocpp.org>)
	id 1X57Sv-0005ta-AY
	for gclcip-std-proposals@m.gmane.org; Thu, 10 Jul 2014 08:04:21 +0200
Original-Received: by mail-qg0-f71.google.com with SMTP id a108sf1537895qge.10
        for <gclcip-std-proposals@m.gmane.org>; Wed, 09 Jul 2014 23:04:20 -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=kjBV8mrgaQ2bmk0fzCfkAnf0POdm4F4bGnNrfJwRy+o=;
        b=HX9I2vYkhBZCAtLK2XiyOfaBu1WtzTffLQie/hJdQlrQ2ItN5N+Km5CRdf3/Fhwh15
         ZasCd3YrP6sHuPQh7dRBt/jr6+zI7jWIWmt4KJ1dDPjchxIF9eC6UPoZ6mahjlSUm2Ms
         KAkn1bh67icGZd9dvlnKNUDmCznUKRQwkj7GvzZ0RGcHcEoI8aiePK+0TtOgdQJsZo0F
         y2FvSYFVKOLl1JsftWLPihNXn1XNZbd1Qe8ba844mHGp32nWsRlGveaBI37hfndnK1L0
         yF90w4x0WV9WzDdAHYsY+r/rNE/nrzLKe2/dU8RfClPY5Zm3kJdYKYRSmbTHQPRl83aG
         WS3A==
X-Gm-Message-State: ALoCoQlOEM3XZSb12g2MAdAkHUwt54uTku1S8KBSx0G4E3ZyVliRtXDjbfq6ubX7cNA31orguLF1
X-Received: by 10.236.189.68 with SMTP id b44mr19880099yhn.4.1404972260128;
        Wed, 09 Jul 2014 23:04:20 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.26.241 with SMTP id 104ls2631570qgv.21.gmail; Wed, 09 Jul
 2014 23:04:19 -0700 (PDT)
X-Received: by 10.224.114.69 with SMTP id d5mr77173641qaq.96.1404972259332;
        Wed, 09 Jul 2014 23:04:19 -0700 (PDT)
Original-Received: from mail-qc0-x22c.google.com (mail-qc0-x22c.google.com [2607:f8b0:400d:c01::22c])
        by mx.google.com with ESMTPS id d2si25654845qge.13.2014.07.09.23.04.19
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Wed, 09 Jul 2014 23:04:19 -0700 (PDT)
Received-SPF: pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:400d:c01::22c as permitted sender) client-ip=2607:f8b0:400d:c01::22c;
Original-Received: by mail-qc0-f172.google.com with SMTP id l6so315550qcy.3
        for <std-proposals@isocpp.org>; Wed, 09 Jul 2014 23:04:19 -0700 (PDT)
X-Received: by 10.224.87.130 with SMTP id w2mr76817236qal.5.1404972259220;
 Wed, 09 Jul 2014 23:04:19 -0700 (PDT)
Original-Received: by 10.224.31.137 with HTTP; Wed, 9 Jul 2014 23:04:19 -0700 (PDT)
In-Reply-To: <66AF41C1-CB37-4311-98EA-D47DBC6068DC@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:c01::22c 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:11779
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11779>

On 10 July 2014 08:48, David Krauss <potswa@gmail.com> wrote:
>
> On 2014=E2=80=9307=E2=80=9310, at 1:11 PM, tomaszkam@gmail.com wrote:
> No, the auto&& does not work with any function that return a any kind of
> reference to subobject of it parameter (including this) is invoked on an
> rvalue. In the examples above you my find:
> std::vector<std::string> f();
> auto&& s =3D f.front();
> //This creates a dangling lvalue reference, and front() has not r-value
> overloads.
>
>
> I think you mean f().front(). As per this thread, or maybe it=E2=80=99s j=
ust my
> extrapolation, the solution is to add an rvalue-ref qualified overload
> returning by value.

The solution, as per this thread, is to not use auto&& for such cases.

> 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".

>
> The whole discussion is about that the changes was made to the optional<T=
>
> that makes following work correctly in cost on introducing temporaries in
> other places:
>
>
> 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.

--=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/.

.
