|
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 00:56:21
On Sat, 28 May 2011 21:50:44 -0700, Mostafa
<mostafa_working_away_at_[hidden]> wrote:
> On Sat, 28 May 2011 21:01:56 -0700, Emil Dotchevski
> <emildotchevski_at_[hidden]> wrote:
>
>> On Sat, May 28, 2011 at 8:37 PM, Mostafa
>> <mostafa_working_away_at_[hidden]> wrote:
>>>> All of the Boost Exception functionality works only if the exceptions
>>>> derive from boost::exception. Your only two choices are to do it
>>>> explicitly or to call boost::throw_exception which does it for you.
>>>
>>> It seems that some functionality doesn't, namely
>>> boost::enable_current_exception, and I was hoping to leverage such
>>> functionality to achieve my aforementioned goal.
>>
>> boost::enable_current_exception enables the
>> boost::current_exception/boost::exception_ptr support by returning an
>> object that derives from boost::exception *and* the type of the passed
>> object.
>>
>> Therefore:
>>
>> throw boost::enable_current_exception(my_exception());
>>
>> satisfies the requirement for deriving from boost::exception without
>> requiring my_exception to derive from boost::exception.
>
> If that is so, then that fact is omitted from the documentation for
> boost::enable_current_exception, please see:
>
> http://www.boost.org/doc/libs/1_46_1/libs/exception/doc/enable_current_exception.html
>
> and the Note at the bottom of the said url seems to imply otherwise, by
> stating "it is preferable to call boost::throw_exception. This is
> guaranteed to throw an exception that derives from boost::exception".
> Can you please add this fact to the above documentation?
>
> The documentation for boost::throw_exception is more clear that it
> derives from the user defined type and boost::exception, see
> http://tinyurl.com/3ks92g8, where it mentions "...
> boost::throw_exception(e) is equivalent to throw
> boost::enable_current_exception(boost::enable_error_info(e)) ...", and
> the documentation for boost::enable_error_info
> (http://tinyurl.com/3zo3yu7) makes it explicit that "... the returned
> object is of an unspecified type that derives publicly from both T and
> boost::exception.". Hence, the reason for my confusion on this matter.
>
> Thanks,
>
> Mostafa
Correction: s/"Can you please add this fact to the above
documentation?"/"Can you please add what you just mentioned to the above
documentation?"
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