Boost logo

Boost :

Subject: Re: [boost] Policy proposal: All user-visible exceptions should be thrown through BOOST_THROW_EXCEPTION
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2012-06-29 12:44:43


Le 29/06/12 09:17, Emil Dotchevski a écrit :
> On Thu, Jun 28, 2012 at 11:53 PM, Vicente J. Botet Escriba<
> vicente.botet_at_[hidden]> wrote:
>
>> Does the use of BOOST_THROW_EXCEPTION implies the use of exception_ptr?
>>
> BOOST_THROW_EXCEPTION simply captures information about the throw location,
> then calls boost::throw_exception.
>
I see that

template<class E> BOOST_ATTRIBUTE_NORETURN inline void throw_exception(
E const & e )
{
     //All boost exceptions are required to derive from std::exception,
     //to ensure compatibility with BOOST_NO_EXCEPTIONS.
     throw_exception_assert_compatibility(e);

#ifndef BOOST_EXCEPTION_DISABLE
     throw enable_current_exception(enable_error_info(e));
#else
     throw e;
#endif
}

 From the documentation, enable_current_exception let me think that we
not only BOOST_THROW_EXCEPTION but boost::throw_exception immplies the
use of exception_ptr, isn't it? Am I missing something evident?

Best,
Vicente

      enable_current_exception

#include <boost/exception/enable_current_exception.hpp>

namespace
boost
     {
     template<class T>
     ---unspecified---enable_current_exception( T const& e );
     }

        Requirements:

  * T must be a class with an accessible no-throw copy constructor.
  * If T has any virtual base types, those types must have an accessible
    default constructor.

        Returns:

An object of /unspecified/ type which derives publicly from T. That is,
the returned object can be intercepted by a catch(T &).

        Description:

This function is designed to be used directly in a throw-expression to
enable the exception_ptr support in Boost Exception. For example:

class
my_exception:
     public std::exception
     {
     };

....
throw boost::enable_current_exception(my_exception());

Unless enable_current_exception is called at the time an exception
object is used in a throw-expression, an attempt to copy it using
current_exception may return an exception_ptr which refers to an
instance of unknown_exception. See current_exception for details.

        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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk