220 33540 <CAFk2RUbdEQMQB4qLCDeaHeF0Q4ntbZG7-Cuf0X2G8d5+Dpf1Pw@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Ville Voutilainen <ville.voutilainen@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Catch block for multiple exceptions
Date: Wed, 2 Aug 2017 21:40:31 +0300
Lines: 62
Approved: news@gmane.org
Message-ID: <CAFk2RUbdEQMQB4qLCDeaHeF0Q4ntbZG7-Cuf0X2G8d5+Dpf1Pw@mail.gmail.com>
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>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: blaine.gmane.org 1501699238 24371 195.159.176.226 (2 Aug 2017 18:40:38 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 2 Aug 2017 18:40:38 +0000 (UTC)
To: "ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC5JHI7A7ALRBINZRDGAKGQEP5BZIFQ@isocpp.org Wed Aug 02 20:40:34 2017
Return-path: <std-proposals+bncBC5JHI7A7ALRBINZRDGAKGQEP5BZIFQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pg0-f69.google.com ([74.125.83.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC5JHI7A7ALRBINZRDGAKGQEP5BZIFQ@isocpp.org>)
	id 1dcyZJ-0005mt-74
	for gclcip-std-proposals@m.gmane.org; Wed, 02 Aug 2017 20:40:29 +0200
Original-Received: by mail-pg0-f69.google.com with SMTP id 16sf58249335pgg.8
        for <gclcip-std-proposals@m.gmane.org>; Wed, 02 Aug 2017 11:40:35 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1501699234; cv=pass;
        d=google.com; s=arc-20160816;
        b=zS4XVWCkd8C3L3jl6tbOziO05zZokE3OGXcWSezHwLLoh7X1guOTMu2jo5OV0nlkCl
         VnOubBtLsKesJt1PCUbh8eModejjRmLVnw8iO9FD/hEQXn0Yc4keZeMjATheCgEmmQnS
         AtePPUDH6MWaZq4ii34kYjThGsjCy0Nmjj19M4G9GmcZ8zN+HovKWj+vvjIF4NMhQpDG
         mr5eR0EZe5fAHqXuoV6gqIkLR5h8JNIdJYx87MBXVV14XpZLQf5BBDqpDHwpI1gSfKHe
         okOhe4RLbvCfcdfvYdDlVIUHYqC0lH9ReiywvsK3MlMBdrfUrYGp0TT6VYyaAN1bEjG4
         ZPeg==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:references:in-reply-to:mime-version:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=3sGWVH9zXGWUHI1ps8pc+hILQbd/KycF5xoNmF7yK0k=;
        b=YjtRNkR6zXFXrCF1ur/tVhL3KOOLGNsrwejxZ55nDCddA6lKktZZR9rLNwf8mprZsK
         4HLW2uCyNZ6hBiXd7m5giOgmEn/iv6HrREC8jlo2aozWs4ozpcK4qUPBiJWGb0Qa7Oy8
         UL/UAZ5D6Y9GRuc5itQobEgK4f7vCIdxwTIl7tXbHvJc/8omeRb+Enk7HRUdQE4LPfro
         rnvTpephdlDR9Sg9UxrUKS2cxgKERfDSSZ2e5NCwHtAoAPMMqeMaFp/AI70Yf4z1ugqw
         vXIwrYZ43x/czOuNZ2AMf2/+MZ/yfvMTdddQcrZ4etqcqTpo6by2wMhMGqPEZ2ojs7ov
         smNQ==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.b=WHiNd1BI;
       spf=pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:400c:c05::22d as permitted sender) smtp.mailfrom=ville.voutilainen@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject: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;
        bh=3sGWVH9zXGWUHI1ps8pc+hILQbd/KycF5xoNmF7yK0k=;
        b=iyzo5ZPswicKMvrU7nj9Ro/DSzF2bMZd47Ptcd3rH64nRlzxxmiY/NVztgWvrWDwnx
         8IrsnOJcl+xhIFQ3gPtoBhyoYXs1cl+d59Np0hrtLJXYVe+NQTxbDsPzYbFJi6mNtIKu
         2t/5teCtCPpK/z8ZYweGny02xZdLqRNYd25eqVgoqXQP37ALllUChX0m2FZFhcw9sL/e
         ziXbF8RLmmBG4e9BMcx44d0q28JzBc1SZmPFkbxrTIPBEQ8jvbNWkoPLFC8SvqZqSWCU
         OBdQmm+vpkVwYyAHAVxpMfxFfNTWSIZRBnQ9db9lyMrkTxEhRbZzfTsyP5lL7LiP9o0T
         DrDA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=3sGWVH9zXGWUHI1ps8pc+hILQbd/KycF5xoNmF7yK0k=;
        b=ofreYlBlQVl3GonbY1ovZMBc2I87I1BML0iVf+qoKlO3fFSDHs6IqFWA5ZKoUY/EEY
         j5RQ6ik4/g1zu7FZY/Pun7uybXHUzoQGKgnB4b79i2A040OaF+0P9xb1AOL8DCZs+pvD
         K7wVzr05pa1zgIlIH6h9z0vRlq+vZ5guiXuq+1t5zMsqwwmaZ83KMvuAvicC5lYxj63B
         GIiHeoykNNzWW1OMcjmmfr6ESddSW4JhkyOtoda6ht7NRFxT8+lkr5uOMkhO7tRO1/Ov
         IRc/USmLy8zFqnHkG6KEaoA5SR/+i6nuA21PTj7QVpITctKTM3/zba1uqMw71nSJ8771
         iTtw==
X-Gm-Message-State: AIVw111dQw/VXqbvNqIlk2+rV6f9sHJon313nV5Mvp7ue3lzvZr+9MXy
	5wsOuX9ToiXNZQeN
X-Received: by 10.101.73.129 with SMTP id r1mr17405911pgs.33.1501699234681;
        Wed, 02 Aug 2017 11:40:34 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.79.69 with SMTP id c66ls3879itb.1.canary-gmail; Wed, 02 Aug
 2017 11:40:33 -0700 (PDT)
X-Received: by 10.31.13.14 with SMTP id 14mr14735465vkn.75.1501699233157;
        Wed, 02 Aug 2017 11:40:33 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1501699233; cv=none;
        d=google.com; s=arc-20160816;
        b=ANYZ15KnPD3wMMfwuUtq6ut3Ki6fAAZvSwowb9Q0/erFzyplvtpPiKSA/Fm9GWiTpE
         zAQnQbk9MJkv0Qgi2ETEmTVFACNgmwoH8+2ZSuQnL4PWI0O7bv3JRFfPiTRR47a+CxtK
         9bb0a1ecvBwDOr9qpbSEl3OjoRSw9TLviU6+LitHYcujUg4UX4qghlkCm42QYwH/BVTi
         1/XEA+1jinygcXoGu44nn8oGOEPg2k19iyZ4dq6jRgX2QxkAJHuBBQtwpHbIi0zPQEHG
         JpQ+Ui3a0PYtRMPEnMw1/HwnQFxIcr+NDdIs1C76pT0tEKpnmdWxVidh1AktJ3lUml+m
         zEOA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:references:in-reply-to:mime-version
         :dkim-signature:arc-authentication-results;
        bh=HWi46OsFXX/WAa9fAwUY8eqDhH2dUDLvZyT+/V11cvo=;
        b=gnz5TQyTpDKHSFbLeLa68zb8+H/gCjtS6M6+Ad4BKyhEPPIHSxNVFubS56UAaWFUOd
         mtpJJKGrt4MBg9fEABKcADYk27+IE8XEt+iV0+GX2X3TnAX4FXDMaHrxAkzVB/XqQTCT
         LNTJY3QRtsdOFYFd79NQnB1nlZc4KJFcNVDcy8P2yxSG9XVZyTWpctDU1DOm2ddqNBum
         wUbqeFFMmbl3U+HoYjCMfYiIF9qe/KXzrOUj1WHSKiv+34UU5LnlukceK4ju99W3kg5c
         EsoEEbDVSvaioLMmM+5ihibMSypPzEbUgu3CrQvkHubRHSBJkTcZUMBTZ32pC/f+Sjg+
         Lw0Q==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.b=WHiNd1BI;
       spf=pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:400c:c05::22d as permitted sender) smtp.mailfrom=ville.voutilainen@gmail.com;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com
Original-Received: from mail-vk0-x22d.google.com (mail-vk0-x22d.google.com. [2607:f8b0:400c:c05::22d])
        by mx.google.com with ESMTPS id r45si15341291uai.111.2017.08.02.11.40.33
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 02 Aug 2017 11:40:33 -0700 (PDT)
Received-SPF: pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:400c:c05::22d as permitted sender) client-ip=2607:f8b0:400c:c05::22d;
Original-Received: by mail-vk0-x22d.google.com with SMTP id d124so21287988vkf.2
        for <std-proposals@isocpp.org>; Wed, 02 Aug 2017 11:40:33 -0700 (PDT)
X-Received: by 10.31.134.207 with SMTP id i198mr15195093vkd.72.1501699232630;
 Wed, 02 Aug 2017 11:40:32 -0700 (PDT)
Original-Received: by 10.103.103.65 with HTTP; Wed, 2 Aug 2017 11:40:31 -0700 (PDT)
In-Reply-To: <CA+fGSbMB3=H4hetWu3GFPzUskLP_sh0Q=Q4oxsUsZ6ci-jrpxg@mail.gmail.com>
X-Original-Sender: ville.voutilainen@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.b=WHiNd1BI;       spf=pass (google.com: domain of
 ville.voutilainen@gmail.com designates 2607:f8b0:400c:c05::22d as permitted
 sender) smtp.mailfrom=ville.voutilainen@gmail.com;       dmarc=pass (p=NONE
 sp=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: <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:33540
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/33540>

On 2 August 2017 at 21:05, Ricardo Fabiano de Andrade
<ricardofabianodeandrade@gmail.com> wrote:
> Hum, a template... bikeshedding an alternate syntax:
>
> catch<exceptionA, exceptionB, exceptionC>(auto& e) {
>  ... do something
> }


Boo hiss. Let's just write a solution with the toys C++17 gives us.
Put handler_helper into
a local library of yours and use it like I use it in main:

#include <exception>
#include <iostream>

struct ExcA
{
    void common() const {std::cout << "common in ExcA" << std::endl;}
};

struct ExcB
{
    void common() const {std::cout << "common in ExcB" << std::endl;}
};

struct ExcC
{
    void common() const {std::cout << "common in ExcC" << std::endl;}
};

template <class... Exceptions, class Handler> void handler_helper(Handler h)
{
    ([&](auto&& a) {
        try {
            throw;
        } catch (const decltype(*a)& exc) {
           h(exc);
        } catch (...) {
        }
    }(std::add_pointer_t<Exceptions>()),...);
}

int main()
{
    try {
        //throw ExcA();
        //throw ExcB();
        throw ExcC();
    } catch (...) {
        handler_helper<ExcA, ExcB, ExcC>([](auto&& c) {
            c.common();
        });
    }
}

-- 
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 email 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/CAFk2RUbdEQMQB4qLCDeaHeF0Q4ntbZG7-Cuf0X2G8d5%2BDpf1Pw%40mail.gmail.com.

.
