Boost logo

Boost Users :

From: Zach Laine (whatwasthataddress_at_[hidden])
Date: 2005-11-22 09:19:33


I agree with the objection raised by the original poster. The assertion in
archive/basic_binary_oprimitive.hpp should more properly be an exception.
Standard library ostreams fail silently when in an error state (including
std::ofstreams that fail to open a file). Writing a std::string, int,
double, or any other data to a default-constructed std::ostream is a no-op.
The only exception to this appears to be writing a boost::serialization
archive to a std::ostream, which under some circumstances fails with an
abort when "assert(os.good());" fails in
archive/basic_binary_oprimitive.hpp. There is also an exception thrown
based on the state of the ostream in the same function as this assertion.
The user can choose to catch this if she decides that the default
std::ostream failure policy (a no-op) is acceptible. By putting the
assertion in there, you force the user to always have a valid, writable
std::ostream, which is precisely the opposite of what the user expects from
years of using std::ostreams.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net