Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-10-03 06:49:50


Tobias Schwinger wrote:

> This approach provides better integration. But we're back in
> boilerplate land (as you showed earlier in this thread).

Boilerplate compared to what? You have to keep in mind where we're coming
from:

class my_error: public std::exception
{
private:

    A a_;
    B b_;
    C c_;

public:

    my_error( A a, B b, C c ): a_( a ), b_( b ), c_( c )
    {
    }

    A a() const
    {
        return a_;
    }

    B b() const
    {
        return b_;
    }

    C c() const
    {
        return c_;
    }

    char const * what() const throw()
    {
        // implement what() here - nontrivial
    }
};

Switching to boost::exception actually removes most of the boilerplate code
(at the expense of some memory allocations). The dynamic allocation problem
can likely be addressed by adding an allocator argument to boost::exception.


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