Boost logo

Boost :

From: Sergey Skorniakov (s.skorniakov_at_[hidden])
Date: 2005-02-14 03:47:59


Hello, Robert!
You wrote on Fri, 11 Feb 2005 16:29:39 -0800:

 ??>> I think that basic_xml_oarchive destructor can be more safe if
 ??>> uncaught_exception examination will be added, because put sometimes
 ??>> can
 ??>> throw exceptions:
 ??>>
 ??>> template<class Archive>
 ??>> basic_xml_oarchive<Archive>::~basic_xml_oarchive(){
 ??>> if(!header)
 ??>> return;
 ??>> if (!std::uncaught_exception())
 ??>> this->This()->put("</boost_serialization>\n");

 RR> What happens if this last statement throws another exception?

It can't - last statement will not be executed if any thrown exception is
being currently processed.
But may be better solution is
try {
  this->This()->put("</boost_serialization>\n");
} catch (archive_exception &) // or catch(std::exception) or even
catch(..) - I'm not sure
{}
This should not prevent writing las tag if destructor called in stack
unwinding process for exception that is not related to archive output
operations.
Current CVS version of basic_xml_oarchive destructor compel users to catch
exceptions on every save - without it terminate() called if almost any
output error occurs.

With best regards, Sergey.


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