Boost logo

Boost :

From: Mark Borgerding (mborgerding_at_[hidden])
Date: 2000-07-16 22:34:09


In theory, I love the concept of throw specifications; describing exceptions as part
of the method invocation, almost as part of the signature -- telling both the class
user and the compiler exactly what can possibly be thrown, It seems clear however,
that they can cause a performance hit on some compilers.

Perhaps there is a middle ground.

Since at least one compilers *is* apparently capable of using a throw() to their
benefit (or at least doing no harm) , it would be a shame not to take advantage of
such a compiler. Perhaps we should use a preprocessor macro that would expand to an
empty throw-spec or nothing, depending on the compiler flags. In either case, the
class user will be informed of the behavior of the method with regard to exceptions.
That way, the intent of "throw()" can be documented in the code, even if the macro
expands to nothing.

e.g.

#ifdef BOOST_BAD_EMPTY_THROW_SPEC
# define BOOST_NOTHROW
#else
# define BOOST_NOTHROW throw()
#endif

...

template <class T>
class shared_ptr
{
    T& operator*() const BOOST_NOTHROW { return *ptr; }
}


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