
The explicit handling of std exceptions in boost::current_exception is a fallback, mostly to deal with exceptions emitted by the standard library itself. For user-defined types (such as null_pointer) boost::enable_current_exception should be used at throw time.
Note:
- This slicing of standard exceptions -- while not ideal -- is still better than getting an exception_ptr that refers to boost::unknown_exception.
What about providing an interface: class ClonableException { public: virtual ~ClonableException() {} virtual ClonableException* clone() const = 0; }; The cloning code would query for this interface first and use it (the exception class made by enable_current_exception would inherit from this interface as well) to make a copy. This way user would be able to clone exactly his exceptions. Note that this would also solved problem in enable_current_exception with virtual base classes that are not default constructible - mentioned in earlier thread. And IMO it does not seem complicated to introduce/explain/document/use. Obviously new standard will render it useless however it is not known how long we will await that standard (and its support in arbitrary compilers) while this change seems to be possibly with next Boost version. Adam Badura