220 12064 <d95d4f7c-7d8e-42de-bdb4-9f83bce67b50@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: jeaye <lorgonjortle@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Variadic catch
Date: Fri, 25 Jul 2014 05:58:31 -0700 (PDT)
Lines: 160
Approved: news@gmane.org
Message-ID: <d95d4f7c-7d8e-42de-bdb4-9f83bce67b50@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_2076_1225168522.1406293111232"
X-Trace: ger.gmane.org 1406293123 9123 80.91.229.3 (25 Jul 2014 12:58:43 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 25 Jul 2014 12:58:43 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDMKNZOF2QLBB6FIZGPAKGQETQKJZUI@isocpp.org Fri Jul 25 14:58:36 2014
Return-path: <std-proposals+bncBDMKNZOF2QLBB6FIZGPAKGQETQKJZUI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oa0-f72.google.com ([209.85.219.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDMKNZOF2QLBB6FIZGPAKGQETQKJZUI@isocpp.org>)
	id 1XAf50-0002WJ-8o
	for gclcip-std-proposals@m.gmane.org; Fri, 25 Jul 2014 14:58:34 +0200
Original-Received: by mail-oa0-f72.google.com with SMTP id m1sf25544406oag.7
        for <gclcip-std-proposals@m.gmane.org>; Fri, 25 Jul 2014 05:58:33 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe:content-type;
        bh=qxEYd7Qn7rYeru60TrTvOq5tOMUUF8zHLR+uj9BQtd8=;
        b=EIpyCn/wiS4vk98GyO8wQ61usAfSeA2oqfwwqRC4f9N7Fn6ntsfxXm8qZSaVDzlInr
         uwIG3kZfcKfHJ41v3cyPDwBKa/qXrYXmBAtunofy+r9JcZTqYFDLtwECKDOyHJOmgaMv
         2KuWjCZeHhy88PKhAoD+M2JF7x0gqBsH28xpYgXFSeM7zdyoKjp0uxMzTKf1/Ztb35dI
         /AYaIsMHXzg+K+jaGBVKnjNvkT5g58VYqlkXzlXQbZvzw18Q2g9ADKgPOZiEfZ9dlMEe
         czTnx0uQxISqt7ZpLNOhXZPM0fZgMxNvCLMFXgOJwKc/jjYWKGKa0NFARQ29wTlBgPZs
         6Y9w==
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:message-id:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=qxEYd7Qn7rYeru60TrTvOq5tOMUUF8zHLR+uj9BQtd8=;
        b=JT4NK017nBtVAicaAiyRYdfu9ih+npXboWFjLXgS7UPcI07C0OdFo8hkgfIBs8ciXz
         PATxqYriSbOxtU60tR1T7aK5ZRuJxsgwGrzhwmN33SVnVqrrbnF5+5q+5tcLD7rb+Sfu
         By70i6QLV9nOHNNCRGPOF3lUbunRhfXOpQ+9gD9z6zgR6hPGzljp98dq6Cb5LeN02K3L
         l2vpPWKaK/L0zu6+6nKQON7lsvav9e6T97fyBanSrfPO7elqGkEwsC9+nrqwwp21qg7L
         jMLVM6JJetO+xmJ0h2K7zJ8YuuQB7/g3qu0fyNvCGJAxuz55hj661i3m6SD37o1dn3yB
         OZew==
X-Gm-Message-State: ALoCoQlJ5D/6iWkh8W8HhfeL0av2iFaegrPmp9GnATyqpL4COzAxYB0wFrHTjACcgbyZ4FW53vKk
X-Received: by 10.42.123.148 with SMTP id s20mr7210433icr.8.1406293113301;
        Fri, 25 Jul 2014 05:58:33 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.253.133 with SMTP id aa5ls421861igd.17.canary; Fri, 25 Jul
 2014 05:58:32 -0700 (PDT)
X-Received: by 10.50.20.168 with SMTP id o8mr101848ige.12.1406293112556;
        Fri, 25 Jul 2014 05:58:32 -0700 (PDT)
X-Original-Sender: LorgonJortle@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:12064
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/12064>

------=_Part_2076_1225168522.1406293111232
Content-Type: text/plain; charset=UTF-8

While implementing a unit test framework in modern C++, I found that I 
wanted an interface for expecting exceptions like:

expect_exception<std::runtime_error>([&]{ do_work(); });

This lead me to wonder, "what if it were variadic?"

expect_exception<std::runtime_error, std::out_of_range>([&]{ do_other_work
(); });

Unfortunately, the implementation of this is not possible in C++11 or 
C++1y, since param pack expansion in a catch is impossible. So, I am 
interested in the group's thoughts on an extended syntax for param pack 
expansion, similar to sizeof...(Ts), but for catch. It would work as 
follows, continuing with my previous examples:

template <typename... Ts>
void expect_exception(std::function<void ()> const &f)
try
{ f(); }
catch...(Ts const &ex)
{ std::cerr << ex.what() << std::endl; }

Thanks for your time.
 

-- 

--- 
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

------=_Part_2076_1225168522.1406293111232
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">While implementing a unit test framework in modern C++, I =
found that I wanted an interface for expecting exceptions like:<br><br><div=
 class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); borde=
r-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-w=
rap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"=
><span style=3D"color: #000;" class=3D"styled-by-prettify">expect_exception=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify">std</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">runtime_error</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&gt;([&amp;]{</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> do_work</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">();</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">});</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span></div></code></div><br>This lead me to =
wonder, "what if it were variadic?"<br><br><div class=3D"prettyprint" style=
=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187);=
 border-style: solid; border-width: 1px; word-wrap: break-word;"><code clas=
s=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #000;=
" class=3D"styled-by-prettify">expect_exception</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">runtime_error</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">out_=
of_range</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&g=
t;([&amp;]{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> do_other_work</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">});</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div><=
/code></div><br>Unfortunately, the implementation of this is not possible i=
n C++11 or C++1y, since param pack expansion in a catch is impossible. So, =
I am interested in the group's thoughts on an extended syntax for param pac=
k expansion, similar to sizeof...(Ts), but for catch. It would work as foll=
ows, continuing with my previous examples:<br><br><div class=3D"prettyprint=
" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187=
, 187); border-style: solid; border-width: 1px; word-wrap: break-word;"><co=
de class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color=
: #008;" class=3D"styled-by-prettify">template</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">typename</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">...</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettif=
y">Ts</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> expect_exception</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">function</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">()&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">c=
onst</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">f</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">try</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> f</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">catch</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">...(</span><span style=3D"color: =
#606;" class=3D"styled-by-prettify">Ts</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
ex</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">cerr </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">&lt;&lt;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> ex</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">what</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;&lt;</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">endl</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">}</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span></div></code></div><br>Thanks for your time.<br>&nbsp=
;<br></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_2076_1225168522.1406293111232--

.
