Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-08-09 09:15:17


From: "Lars Gullik Bjønnes" <larsbj_at_[hidden]>
>
> We are currently compiling LyX without exceptions and are thus
> required to also compile Boost libs without exceptions. Some of the
> boost libs already have preprocessor switches to accomplish this, and
> some don't.
>
> LyX does not use every Boost lib in exsistance so this patch will be a
> bit limited.
>
> However... We have decided that whenever a Boost lib would throw we
> will assert instead. We realize of course that this is not the best
> solution in all cases, but can be made to work with some extra effort
> in almost every situation.
>
> Anyway, this is the current difference between "LyX Boost" and the
> Boost CVS for us to accomplish this. The user.hpp are mostly for
> reference, apart from the BOODT_NO_EH_ASSERT macro, with is modeled on
> the similar macro in Boost.Regex.

I propose the following alternative to your patch:

* New header boost/throw.hpp:

#ifdef BOOST_NO_EXCEPTIONS

#include <exception>

void boost_throw(std::exception const & e); // user defined

#else

template<class E> void boost_throw(E const & e)
{
    throw e;
}

#endif

* shared_count changes:

- if(use_count_ == 0 && weak_count_ != 0) throw use_count_is_zero();
+ if(use_count_ == 0 && weak_count_ != 0)
::boost_throw(use_count_is_zero());

and similarly for the other occurence:

+#ifndef BOOST_NO_EXCEPTIONS
         try
         {
             pi_ = new counted_base_impl<P, D>(p, d, 1, 1);
@@ -244,6 +248,10 @@
             d(p); // delete p
             throw;
         }
+#else
+ pi_ = new counted_base_impl<P, D>(p, d, 1, 1);
+ if(pi_ == 0) ::boost_throw(std::bad_alloc());
+#endif

Comments?


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