Boost logo

Boost Users :

Subject: Re: [Boost-users] [exception] Using Boost.Exception infrastructure without using boost::exception
From: Mostafa (mostafa_working_away_at_[hidden])
Date: 2011-05-29 01:42:15


On Sat, 28 May 2011 22:25:08 -0700, Emil Dotchevski
<emildotchevski_at_[hidden]> wrote:

> On Sat, May 28, 2011 at 10:21 PM, Mostafa
> <mostafa_working_away_at_[hidden]> wrote:
>> My Requirements:
>> ----------------
>> To use Boost.Exception tools to make my exceptions transportable between
>> threads without explicitly or implicitly deriving from Boost.Exception.
>>
>> So it seems I'm halfway there with "throw
>> boost::enable_current_exception(my_exception());". Now I would like to
>> rethrow from some catch site, it is my understanding then that I would
>> need
>> to use boost::rethrow_exception() (in order to stay within the
>> parameters of
>> my requirements). But boost::rethrow_exception requires a
>> boost::exception_ptr reference (which seems can only be gotten via
>> boost::current_exception). Now, does using "throw
>> boost::enable_current_exception(my_exception());" with class
>> my_exception
>> which does not derive from boost::exception support the exception_ptr
>> functionality that is need for boost::rethrow_exception?
>
> Yes.

Thank you.

Now, may the above fact be added as a special section to Boost.Exception
documentation so others don't have to go through the same long-winded
discussion that I did?

And the reason for my caution and me posting here was the Note at the
bottom of the documentation for boost::enable_current_exception (see
http://tinyurl.com/3tqsqw6):

"Note: Instead of using the throw keyword directly, it is preferable to
call boost::throw_exception. This is guaranteed to throw an exception that
derives from boost::exception and supports the exception_ptr
functionality."

Which to the casual reader implies that boost::enable_current_exception
does not support the boost::exception_ptr functionality. Maybe taking out
"and supports the exception_ptr functionality" or explicitly stating that
boost::enable_current_exception also supports such functionality will
alleviate any confusion or potential confusion on the part of the users.

Thanks,

Mostafa


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net