220 16161 <ff7efd99-6442-4976-b385-059bf0ae88a3@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: deprecate catch exception by value, at least in
 some instances?
Date: Mon, 9 Feb 2015 15:29:05 -0800 (PST)
Lines: 109
Approved: news@gmane.org
Message-ID: <ff7efd99-6442-4976-b385-059bf0ae88a3@isocpp.org>
References: <8be36e16-97f4-4d8a-8500-c045195b2f6b@isocpp.org> <56A0729B-434D-4300-B4FF-5D744D81506C@gmail.com> <ccb33924-a8fa-4395-9b7f-892a5a36cf49@isocpp.org>
 <CA59C0FC-E1F0-4AA2-A7D4-CEF0B3F962BD@gmail.com>
 <bea778eb-009c-4e95-9a31-159738282c27@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_29_803476715.1423524545068"
X-Trace: ger.gmane.org 1423524551 31999 80.91.229.3 (9 Feb 2015 23:29:11 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 9 Feb 2015 23:29:11 +0000 (UTC)
Cc: gmisocpp@gmail.com
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDLZJYWNDQIMFBPFUYCRUBFA4HJ7A@isocpp.org Tue Feb 10 00:29:11 2015
Return-path: <std-proposals+bncBDLZJYWNDQIMFBPFUYCRUBFA4HJ7A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ig0-f198.google.com ([209.85.213.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDLZJYWNDQIMFBPFUYCRUBFA4HJ7A@isocpp.org>)
	id 1YKxlL-0007DI-Ua
	for gclcip-std-proposals@m.gmane.org; Tue, 10 Feb 2015 00:29:08 +0100
Original-Received: by mail-ig0-f198.google.com with SMTP id hl2sf123075777igb.1
        for <gclcip-std-proposals@m.gmane.org>; Mon, 09 Feb 2015 15:29:06 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:content-type:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=Q1D91TcVk4SOOThan0KcqLlZTXSP9y50p8hnhQ7vAYk=;
        b=c2jNrMWU5jiIuxx60zRvtmORq4p6M3MVFpu+lAlnBT6aYqqmfBDEWmKn7Pq41a5AwV
         VC1PSuVWghXmz6tx854F8OfAunMqI2JynbdPHPpHkPfMvGr4OS9EcoaxKTMoEFj5Iufy
         XLkXtA0HDNluGCEsi3yIf25dHo633EHceoiz2ZfoAaggXPMYG+IT1OHUE0um0JJJo9JP
         n6QFuWx0+c6JNJ8NPDzBmDBELbpqXX8XZG3XUMQiwCA7y1QLgvEkHmtQ9HDJ7QzWTI+g
         dYv8rhAnpPzIZzyg+p9vmEN+MSHg83RI3DGq4jqEyn6aHUo2Zb0fUHIyXeuqT0gUFYSh
         8K+g==
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:cc:message-id:in-reply-to
         :references:subject:mime-version:content-type:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=Q1D91TcVk4SOOThan0KcqLlZTXSP9y50p8hnhQ7vAYk=;
        b=EC6YkIP5VDdnn95xHvxSCxWxkajJlqpC1FJ+k0WXexDYbwkt+Zex841GBNJicWvtHj
         v09VcDeydYMqYcy31Y23y1hRfBNoQKWq9baNU2TpT/UeYLVkuwZWIlxgwR3HtifTr/lO
         qTZw6F505+guoR9bxPN7odU0iCg2rZTJVEnVt74jjFf9wjxmZ2hSpt1c1RBHjO8OgxOq
         zzwZrfZNOU0NVOpEPRP/w1hb0ePLW6E1rVaz9cNIMqIonyUnTAhTg+1POQ7tXyk/bhlY
         rPdGw3NS8M9ozyLKxSS8WBpkTniXUnquJQwWK7u8v+4NO8IrpctkzZyhswrlvF2cuiCJ
         E8PA==
X-Gm-Message-State: ALoCoQkBoe5j2/HxuDfRKaNaKU31H67VMMrtxthK90Tn3b3QJkWXAiW0HkRjEuc51lcJ/wasoHhQ
X-Received: by 10.50.87.97 with SMTP id w1mr16167939igz.1.1423524546694;
        Mon, 09 Feb 2015 15:29:06 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.150.202 with SMTP id y193ls1516452iod.78.gmail; Mon, 09
 Feb 2015 15:29:06 -0800 (PST)
X-Received: by 10.50.25.194 with SMTP id e2mr276817igg.16.1423524546038;
        Mon, 09 Feb 2015 15:29:06 -0800 (PST)
In-Reply-To: <bea778eb-009c-4e95-9a31-159738282c27@isocpp.org>
X-Original-Sender: arthur.j.odwyer@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:16161
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/16161>

------=_Part_29_803476715.1423524545068
Content-Type: multipart/alternative; 
	boundary="----=_Part_30_655976669.1423524545068"

------=_Part_30_655976669.1423524545068
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Sunday, February 8, 2015 at 5:36:48 PM UTC-8, gmis...@gmail.com wrote:
>
> On Monday, February 9, 2015 at 1:28:33 PM UTC+13, David Krauss wrote:
>>
>>
>> Perhaps it=E2=80=99s hard to remember because it doesn=E2=80=99t make mu=
ch of a=20
>> difference either way. There=E2=80=99s no such thing as throwing by refe=
rence, at=20
>> all. You can get a little extra efficiency by using std::move when=20
>> throwing, but there=E2=80=99s not really much point. [...]
>>
>
> Hey that all strangely leads me off to a different idea:
> When we throw x, why can't we treat that as a move in some instances, lik=
e=20
> return does!?
>

There are two things going on here:
- "return x;" and "throw x;", where x is a local variable, will both treat=
=20
x as an rvalue rather than an lvalue. (This is specified in 12.8 /32 of=20
draft standard N4296.)
- Copy/move elision. "return x;" and "throw x;" are both permitted to elide=
=20
the copy/move construction. (These are specified in 12.8 /31.1 and /31.2=20
respectively.)

In other words, "throw x;" will neither copy nor move in the usual case;=20
but if you somehow manage to disable copy elision in your compiler, it will=
=20
still move. It is not *permitted* to make a copy, unless there are=20
extenuating circumstances (such as the move constructor having been=20
deleted).

Writing "throw std::move(x);" will inhibit move elision, so don't do that.

=E2=80=93Arthur

--=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_30_655976669.1423524545068
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Sunday, February 8, 2015 at 5:36:48 PM UTC-8, gmis...@g=
mail.com wrote:<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=
">On Monday, February 9, 2015 at 1:28:33 PM UTC+13, David Krauss wrote:<blo=
ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;padding-lef=
t:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-=
style:solid"><div><br><div>Perhaps it=E2=80=99s hard to remember because it=
 doesn=E2=80=99t make much of a difference either way. There=E2=80=99s no s=
uch thing as throwing by reference, at all. You can get a little extra effi=
ciency by using <font face=3D"Courier">std::move</font> when throwing, but =
there=E2=80=99s not really much point. [...]</div></div></blockquote><div><=
br></div><div>Hey that all strangely leads me off to a different idea:</div=
><div>When we throw x, why can't we treat that as a move in some instances,=
 like return does!?</div></div></blockquote><div><br></div><div>There are t=
wo things going on here:</div><div>- "return x;" and "throw x;", where x is=
 a local variable, will both treat x as an rvalue rather than an lvalue. (T=
his is specified in 12.8 /32 of draft standard N4296.)</div><div>- Copy/mov=
e elision. "return x;" and "throw x;" are both permitted to elide the copy/=
move construction. (These are specified in 12.8 /31.1 and /31.2 respectivel=
y.)</div><div><br></div><div>In other words, "throw x;" will neither copy n=
or move in the usual case; but if you somehow manage to disable copy elisio=
n in your compiler, it will still move. It is not *permitted* to make a cop=
y, unless there are extenuating circumstances (such as the move constructor=
 having been deleted).</div><div><br></div><div>Writing "throw std::move(x)=
;" will inhibit move elision, so don't do that.</div><div><br></div><div>=
=E2=80=93Arthur</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_30_655976669.1423524545068--
------=_Part_29_803476715.1423524545068--

.
