220 33551 <54580edb-4a76-4241-b5c8-19ccbc1a562e@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Catch block for multiple exceptions
Date: Wed, 2 Aug 2017 15:56:38 -0700 (PDT)
Lines: 141
Approved: news@gmane.org
Message-ID: <54580edb-4a76-4241-b5c8-19ccbc1a562e@isocpp.org>
References: <effe744d-f832-42c7-9b2a-ef31551067d0@isocpp.org>
 <deaedeb0-a699-49e9-826a-c41e674902c0@isocpp.org> <CAEfefmzCWDwP2ha7UfvvPrW_56TT4DEgvwRyxWm=6gS_GZc7pA@mail.gmail.com>
 <4126837.jZlGhgVnua@tjmaciei-mobl1> <d14636de-fb57-47b3-8666-7976ccdb6fe8@isocpp.org>
 <d58143f8-c128-3745-b835-1e04a5760d0d@gmail.com> <CA+fGSbMB3=H4hetWu3GFPzUskLP_sh0Q=Q4oxsUsZ6ci-jrpxg@mail.gmail.com>
 <CAFk2RUbdEQMQB4qLCDeaHeF0Q4ntbZG7-Cuf0X2G8d5+Dpf1Pw@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_6400_1396982999.1501714598251"
X-Trace: blaine.gmane.org 1501714600 9615 195.159.176.226 (2 Aug 2017 22:56:40 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 2 Aug 2017 22:56:40 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDLZJYWNDQIKNMMJZQCRUBG5RJZQY@isocpp.org Thu Aug 03 00:56:34 2017
Return-path: <std-proposals+bncBDLZJYWNDQIKNMMJZQCRUBG5RJZQY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw0-f200.google.com ([209.85.161.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDLZJYWNDQIKNMMJZQCRUBG5RJZQY@isocpp.org>)
	id 1dd2Z8-0002Ab-8Z
	for gclcip-std-proposals@m.gmane.org; Thu, 03 Aug 2017 00:56:34 +0200
Original-Received: by mail-yw0-f200.google.com with SMTP id c13sf95466105ywa.2
        for <gclcip-std-proposals@m.gmane.org>; Wed, 02 Aug 2017 15:56:40 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        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;
        bh=+qpqUmbVVh/wQo9E9Tle/t+oh++lHQxyr30EuipXSs8=;
        b=JwOutKZTzTaXjbjVxBYQqpUFx4U04BrV5qZjnvwM/baFyUMxOe2jO4oNuHz20Zz2tN
         xYORWfZUAkVyR3QpykyDUlqHKGQB+g3QjGgEQcHzGSw+PHYY3Hp4VLw09OPquiIhZY6o
         eY3pIBT4810jEHj12mEnenOVlwYC5ZNNzFfstKQ2Kthza/JvH/Fnal/krUzbryfOc9VM
         QAwB/cZleXQ0/XTtSgwIQsBv3sTXRjNXadt38OXGm2yPWHbZFrE9XVBvhfv/MLlm9uPb
         uNCaxkia2V29Dflz4xvk+kFEF2BzHGcbZMpy8ZMKdkvAfvrmfAManJggdkuNmQl/SMEt
         /DcQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        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;
        bh=+qpqUmbVVh/wQo9E9Tle/t+oh++lHQxyr30EuipXSs8=;
        b=DaHiq45Ywuzc/50hViuzk1pxxYSU4cEW6Uglp9RVqz8F4Y2thLuOMF3lIRGiMzI52W
         DANb67PsexirKN854Gg+xlKHv2SikiJqQVGuxkZD2PbpnLiACNR5CwucO16EGAG0wE4/
         CWy6X2SYee1H3qb5lfAn2CUkDnaz4ntkd9Zk/uaxqbA2Y2ZD3REXR/u3h7YCXb2ixbmV
         OdbYAxJhassbiyHgVHVJ27XKdZC8948Yv10e6gIYARBhhxedgeFo+DoJiJzTdTfh3bHk
         gW2HQ7QQ5HnQRyWGXK6yEaj9+CD1di4DJBCKggD8gdggNX/hzThFoeeE/tx9VH69rrDo
         nIlQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        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:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=+qpqUmbVVh/wQo9E9Tle/t+oh++lHQxyr30EuipXSs8=;
        b=j6uzxV2ihBzfYGsc3pYfa4CwoIcuZhFZO/mbQprNMCo34b3HRh55alIfG0jLtnzAFy
         rmqzafFn9BuPZbjUDX5kY7TC0mds/evN5j5jQ3gzuDa6EkKPD3QLFM9lNT/8MiO1bnNK
         EvuUGzL/98NUXM5Kswy3X+6F9F+nQrn+t7QyAM8lxGq5ZTQQ4BC9qB1Qnf2JMe7jGtYU
         EUrDkulFQ6NzcVn/sL6CsKpXFpNeADh6OmYar2oNQd7s2fm1Fh8JNzDwNatsYZN+Y7Rw
         pqWyaxzwnpwxSGJDrCcJ+xd7p2PfrYO0cABlBTrx7awog3ChJaRYeS5FbURJFhhoQb50
         37IA==
X-Gm-Message-State: AIVw111Z/KpvkXeHaqO8TsI8fJO2mk2Pq2r1OU9yMysjRv0+M7f43pmD
	Lktw259bDxpW7R21
X-Received: by 10.13.203.20 with SMTP id n20mr18175335ywd.79.1501714600037;
        Wed, 02 Aug 2017 15:56:40 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.19.105 with SMTP id b102ls363699ioj.19.gmail; Wed, 02 Aug
 2017 15:56:38 -0700 (PDT)
X-Received: by 10.31.160.13 with SMTP id j13mr51526vke.25.1501714598735;
        Wed, 02 Aug 2017 15:56:38 -0700 (PDT)
In-Reply-To: <CAFk2RUbdEQMQB4qLCDeaHeF0Q4ntbZG7-Cuf0X2G8d5+Dpf1Pw@mail.gmail.com>
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: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://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>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:33551
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33551>

------=_Part_6400_1396982999.1501714598251
Content-Type: multipart/alternative; 
	boundary="----=_Part_6401_1807263504.1501714598251"

------=_Part_6401_1807263504.1501714598251
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Wednesday, August 2, 2017 at 11:40:35 AM UTC-7, Ville Voutilainen wrote:
>
> On 2 August 2017 at 21:05, Ricardo Fabiano de Andrade=20
> <ricardofabi...@gmail.com <javascript:>> wrote:=20
> > Hum, a template... bikeshedding an alternate syntax:=20
> >=20
> > catch<exceptionA, exceptionB, exceptionC>(auto& e) {=20
> >  ... do something=20
> > }=20
>
>
> Boo hiss. Let's just write a solution with the toys C++17 gives us.
>

FYI, this exact puzzle (variadic "catch") was discussed in the=20
#meta_programming Slack channel on June 30th; participants were Vittorio=20
Romeo, Barry Revzin, Eric Niebler, Peter Dimov, and myself (belatedly). My=
=20
solution is here <https://wandbox.org/permlink/egm66nYboBjo0May>. Its punch=
=20
line is:

        try {
            throw Derived();  // this is just a placeholder for some code=
=20
that might throw
        } catch (...) {
            variant_catch<const Derived&, const Base&>([](auto&& e) {
                printf("caught %s (%s)\n", typeid(e).name(),=20
__PRETTY_FUNCTION__);
            });
        }

but with the caveat that this signature (also provided at the Wandbox link=
=20
above) will be more performant (not that we care about the performance of=
=20
the exceptional path, of course):

    variant_catch<const Derived&, const Base&>([&]() {
        throw Derived();  // this is just a placeholder for some code that=
=20
might throw
    }, [](auto&& e) {
        printf("caught %s (%s)\n", typeid(e).name(), __PRETTY_FUNCTION__);
    });

HTH,
=E2=80=93Arthur

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/54580edb-4a76-4241-b5c8-19ccbc1a562e%40isocpp.or=
g.

------=_Part_6401_1807263504.1501714598251
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wednesday, August 2, 2017 at 11:40:35 AM UTC-7, Ville V=
outilainen wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 2 August 2=
017 at 21:05, Ricardo Fabiano de Andrade
<br>&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
hISI7gbZBQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#39;javascript:&=
#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#39;;return true=
;">ricardofabi...@<wbr>gmail.com</a>&gt; wrote:
<br>&gt; Hum, a template... bikeshedding an alternate syntax:
<br>&gt;
<br>&gt; catch&lt;exceptionA, exceptionB, exceptionC&gt;(auto&amp; e) {
<br>&gt; =C2=A0... do something
<br>&gt; }
<br>
<br>
<br>Boo hiss. Let&#39;s just write a solution with the toys C++17 gives us.=
<br></blockquote><div><br></div><div>FYI, this exact puzzle (variadic &quot=
;catch&quot;) was discussed in the #meta_programming Slack channel on June =
30th; participants were Vittorio Romeo, Barry Revzin, Eric Niebler, Peter D=
imov, and myself (belatedly). My solution is <a href=3D"https://wandbox.org=
/permlink/egm66nYboBjo0May">here</a>. Its punch line is:</div><div><br></di=
v><div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 try {</font></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 throw Derived();</font><span style=3D"font-=
family: &#39;courier new&#39;, monospace;">=C2=A0</span><span style=3D"font=
-family: &#39;courier new&#39;, monospace;">=C2=A0// this is just a placeho=
lder for some code that might throw</span></div><div><font face=3D"courier =
new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 } catch (...) {</font></div><di=
v><font face=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 variant_catch&lt;const Derived&amp;, const Base&amp;&gt;([](auto&amp=
;&amp; e) {</font></div><div><font face=3D"courier new, monospace">=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf(&quot;caught %s (%s=
)\n&quot;, typeid(e).name(), __PRETTY_FUNCTION__);</font></div><div><font f=
ace=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 })=
;<br></font></div><div><font face=3D"courier new, monospace">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 }</font></div></div><div><br></div><div>but with the caveat t=
hat this signature (also provided at the Wandbox link above) will be more p=
erformant (not that we care about the performance of the exceptional path, =
of course):</div><div><br></div><div><div><font face=3D"courier new, monosp=
ace">=C2=A0 =C2=A0 variant_catch&lt;const Derived&amp;, const Base&amp;&gt;=
([&amp;]() {</font></div><div><font face=3D"courier new, monospace">=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 throw Derived(); =C2=A0// this is just a placeholder f=
or some code that might throw</font></div><div><font face=3D"courier new, m=
onospace">=C2=A0 =C2=A0 }, [](auto&amp;&amp; e) {</font></div><div><font fa=
ce=3D"courier new, monospace">=C2=A0 =C2=A0 =C2=A0 =C2=A0 printf(&quot;caug=
ht %s (%s)\n&quot;, typeid(e).name(), __PRETTY_FUNCTION__);</font></div><di=
v><font face=3D"courier new, monospace">=C2=A0 =C2=A0 });</font></div></div=
><div><br></div><div>HTH,</div><div>=E2=80=93Arthur</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/54580edb-4a76-4241-b5c8-19ccbc1a562e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/54580edb-4a76-4241-b5c8-19ccbc1a562e=
%40isocpp.org</a>.<br />

------=_Part_6401_1807263504.1501714598251--

------=_Part_6400_1396982999.1501714598251--

.
