220 8407 <775b0fd7-2b3a-4667-b776-d13efe0d2fdb@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Cassio Neri <cassio.neri@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: [exception_ptr] exception_ptr_cast: cast to the
 stored exception a la any_cast
Date: Mon, 6 Jan 2014 07:33:23 -0800 (PST)
Lines: 90
Approved: news@gmane.org
Message-ID: <775b0fd7-2b3a-4667-b776-d13efe0d2fdb@isocpp.org>
References: <52C7F46C.3060702@wanadoo.fr>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_97_26744951.1389022403263"
X-Trace: ger.gmane.org 1389022416 24463 80.91.229.3 (6 Jan 2014 15:33:36 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Mon, 6 Jan 2014 15:33:36 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDEYBBEU2UGBBREZVOLAKGQE6F5L5KY@isocpp.org Mon Jan 06 16:33:44 2014
Return-path: <std-proposals+bncBDEYBBEU2UGBBREZVOLAKGQE6F5L5KY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oa0-f69.google.com ([209.85.219.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDEYBBEU2UGBBREZVOLAKGQE6F5L5KY@isocpp.org>)
	id 1W0CBB-0003uO-Tb
	for gclcip-std-proposals@m.gmane.org; Mon, 06 Jan 2014 16:33:26 +0100
Original-Received: by mail-oa0-f69.google.com with SMTP id m1sf7813452oag.4
        for <gclcip-std-proposals@m.gmane.org>; Mon, 06 Jan 2014 07:33:24 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        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
         :content-type;
        bh=zpcWa3UtWe0IK3RRJVXZzOem+UXQCVKDlFLlLd/mvXc=;
        b=TbLAfzQ9jbr2JuK7FpWWow9xwnSkSuAk01Ds/giyVb97e8yEtIHJXjZ9bEvzhnvk9J
         Bw2iFluDcEC5a/IboPJ/3ljow3olpjqVH+ZYHj5vwu6EjCXwVwyZT4p7Ufk3iu96SGco
         /CXwgB8+BJ4iRmaq6NWkrE4FnajiBuHQKbWIcTzGCXXaiY83h5nL1aUjXMPv5K1YA4ZF
         AxyWZo/XVkGBzKT+TrocoUrXxn5m37fluphoDNen/Z8fc7Q3W23XVs4Imz44CdZ4a7MB
         f6Zu+zUC+ce8beHlPqoOGgCp6sxCBtrqVSLJwIl5l4aC2R8VDUBk0lBAbSvLDjcUrQQ9
         pctg==
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: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:content-type;
        bh=zpcWa3UtWe0IK3RRJVXZzOem+UXQCVKDlFLlLd/mvXc=;
        b=hUqS9B+PbptHe8kmylWuLedaGl2gdo1YqS+xcI9JWLSNWrEyixcLWNJ6b1oGkTk6MF
         Td8Z2TcxwaVApXwmTS9az5DSHtIVKqtq7do+p8bzUeAcZZKF57zF1CS+yUF7eijMNav3
         UJ+c+jAfuX1zCXpGHTacfCLcX/wKPas0t70m4YOsiOBAh/5M7LP34gZLvlYOKiINJ75e
         xQV7CLoNagfGVDcgPzHSsV0eREqSETcwn8HgeBqQX4hwv6eL13STSkoszIVXMkfyl4pi
         crSRyrBc96nf84mWTLwU0n7pc8mrJN+HjKQins5Q4ulUZN/RDwas2EqQHW+A+PY4yXTG
         kAKw==
X-Gm-Message-State: ALoCoQl98p5p3YIv9M+QtuTbisj6D4Mv3GFSCTlycJXkYHXldSx5l8scGB7fYRadEMy24q7xwsT4
X-Received: by 10.43.161.202 with SMTP id mh10mr19381273icc.23.1389022404733;
        Mon, 06 Jan 2014 07:33:24 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.2.69 with SMTP id 5ls5942361qes.98.gmail; Mon, 06 Jan 2014
 07:33:23 -0800 (PST)
X-Received: by 10.49.35.107 with SMTP id g11mr1360336qej.5.1389022403941;
        Mon, 06 Jan 2014 07:33:23 -0800 (PST)
In-Reply-To: <52C7F46C.3060702@wanadoo.fr>
X-Original-Sender: cassio.neri@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:8407
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/8407>

------=_Part_97_26744951.1389022403263
Content-Type: text/plain; charset=ISO-8859-1



On Saturday, January 4, 2014 11:45:48 AM UTC, Vicente J. Botet Escriba 
wrote:
>
>  
> I would like to define a dynamic cast that returns a pointer to the stored 
> exception it the type match
>
> template <class E, class T>
> const E* expected_cast(const expected<T>*);
>
> if (auto ex = expected_cast<NotDivisible*>(&y)) 
> {
>    std::cout <<ex->num <<"," <<ex->den<<std::endl;
> }
>
>
I'm not sure but what about something along these lines?

const E* expected_cast(const expected<T>* y) {
  try {
    if (!y->valid())
        std::rethrow_exception(y->exception_ptr());
  } catch (const E& object) {
     return &obj;
  } catch (...) {
  }
  return nullptr;
}

Is there any lifetime issue here? What if a similar function was part of 
the exceptr_ptr interface?

HTH
Cassio.

-- 

--- 
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_97_26744951.1389022403263
Content-Type: text/html; charset=ISO-8859-1

<div dir="ltr"><br><br>On Saturday, January 4, 2014 11:45:48 AM UTC, Vicente J. Botet Escriba wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
  

    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <br>
    I would like to define a dynamic cast that returns a pointer to the
    stored exception it the type match<br>
    <br>
    template &lt;class E, class T&gt;<br>
    const E* expected_cast(const expected&lt;T&gt;*);<br>
    <br>
    if (auto ex = expected_cast&lt;NotDivisible*&gt;(&amp;<wbr>y)) <br>
    {<br>
    &nbsp;&nbsp;
    std::cout &lt;&lt;ex-&gt;num &lt;&lt;"," &lt;&lt;ex-&gt;den&lt;&lt;std::endl;<br>
    }<br>
    <br></div></blockquote><div><br>I'm not sure but what about something along these lines?<br><br>const E* expected_cast(const expected&lt;T&gt;* y) {<br>&nbsp; try {<br>&nbsp;&nbsp;&nbsp; if (!y-&gt;valid())<br>
    &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::rethrow_exception(y-&gt;exception_ptr());<br>
    &nbsp; } catch (const E&amp; object) {<br>
    &nbsp; &nbsp;&nbsp; return &amp;obj;<br>
    &nbsp; } catch (...) {<br>
    &nbsp; }<br>
    &nbsp; return nullptr;<br>
    }<br><br>Is there any lifetime issue here? What if a similar function was part of the exceptr_ptr interface?<br><br>HTH<br>Cassio.<br></div></div>

<p></p>

-- <br />
&nbsp;<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 email to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

------=_Part_97_26744951.1389022403263--

.
