Boost logo

Boost :

Subject: Re: [boost] Boost and exceptions
From: Robert Ramey (ramey_at_[hidden])
Date: 2012-06-23 19:33:14

Agustín K-ballo Bergé wrote:
> On 23/06/2012 18:25, Robert Ramey wrote:
>> Steven Watanabe wrote:
>>> Actually, inheriting from boost::exception doesn't
>>> work for this. To enable copying you have to throw
>>> using boost::enable_current_exception.
>>> try {
>>> throw enable_current_exception(x);
>>> } catch(...) {
>>> exception_ptr e = current_exception();
>>> }
>>> // move e to another thread
>>> rethrow_exception(e);
>> OK - get it - but I don't see that it adds any value compared to
>> try {
>> throw x;
>> }
>> catch(...){
>> exception_ptr e = std::current_exception();
>> std::rethrow_exception(e); // n3242 18.8}
>> }
> Would you happen to know which compilers implement n3242 already?
> Boost.Exception works for me with the compilers I use everyday, as
> long as the original exception was thrown with enable_current_exception.

hmm - I really don't know. It looks like boost exception implements
this functionality for those compilers which don't have it. Actually
this is really good thing in my opinion. If this were a separate
library part of the boost directory/namespace I think it would be
good addition.

But this facility is included in the same library as another facility
useful to users. So addressing of one problem - non-conforming
compilers is not orthogonal to the other problem - helpful facilities
for users. It's not fine grained enough for my taste.

Robert Ramey

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