Boost logo

Boost :

Subject: Re: [boost] [function] function wrapping with no exception safetyguarantee
From: David Abrahams (dave_at_[hidden])
Date: 2010-10-13 10:42:42

At Tue, 12 Oct 2010 18:50:13 -0700,
Emil Dotchevski wrote:
> On Tue, Oct 12, 2010 at 6:38 PM, Dave Abrahams <dave_at_[hidden]> wrote:
> > On Tue, Oct 12, 2010 at 7:59 PM, Peter Dimov <pdimov_at_[hidden]> wrote:
> >> The issue is not coupling with Boost.Exception, the issue is that the user
> >> has to supply a definition of boost::throw_exception when exceptions are
> >> disabled. This was true before there were Boost.Exception.
> >
> > Okay, and could someone please explain to me what is wrong with that
> > requirement?
> Maybe someone else should do that but I think I understand it.
> Suppose you're a subcontractor who develops a library for another
> company. Internally, you use boost::function and so your library
> requires the executable to define boost::throw_exception.

Ooooh. We don't have a way for the library to define
boost::throw_exception. Riiight.

I think we could fix that pretty easily, though. Those places in
Boost that use boost::throw_exception could switch to something like


where we define:

  namespace boost {

  template <class X, bool=false>
  struct throw_
      throw_(X const& x) { boost::throw_exception(x); }

  namespace detail
    template <class X>
    throw_(X const& e)


and then the 3rd-party library author could just:

  namespace boost {

  template <class X>
  struct throw_<X>
      throw_(X const&) { /* whatever */ }

to force the behavior to something else. He'd just need to make sure
that specialization was included before boost::detail::throw_ was

Dave Abrahams
BoostPro Computing

Boost list run by bdawes at, gregod at, cpdaniel at, john at