Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2004-01-02 13:04:46

Could we not consider augmenting throw_exception.hpp to
something like the following? Is there any reason why this
wouldn't be a good idea?

#include <boost/config.hpp>

# include <exception>

namespace boost {

    // user defined
    void throw_exception(std::exception const & e);
    void throw_exception();
    } // namespace boost
    #define BOOST_TRY
    #define BOOST_CATCH(x) if(0)
    template<class E> void throw_exception(E const & e)
        throw e;
    inline void throw_exception()
    #define BOOST_TRY try
    #define BOOST_CATCH(x) catch(x)

} // namespace boost

This would permit me me to do the following:

template<class Archive>
void D::load(Archive & ar, const unsigned int file_version)
        ar >> boost::serialization::make_nvp("b", b1);
        ar >> boost::serialization::make_nvp("b", b2);
    BOOST_CATCH (...){
        // eliminate invalid pointers
        b1 = NULL;
        b2 = NULL;
    // check that loading was correct
    BOOST_CHECK(b1 == b2);

Robert Ramey

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