[serialization] assertion in basic_binary_oprimitive::save_binary() revisited
A while ago I brought up what I considered (and still consider) to be a serious problem in basic_binary_oprimitive::save_binary(). The problem is the assert at the end of the function: assert(os.good()); There are a number of reasons why doing this is a bad idea, but the discussion on this issue was dropped flat on the floor. Is there any possibility of discussing alternatives to this assertion? At the very least, can I get an explanation of why an assert is correct to which counter-arguments might be considered? -- Austin Bingham
Austin Bingham wrote:
A while ago I brought up what I considered (and still consider) to be a serious problem in basic_binary_oprimitive::save_binary(). The problem is the assert at the end of the function:
assert(os.good());
There are a number of reasons why doing this is a bad idea, but the discussion on this issue was dropped flat on the floor. Is there any possibility of discussing alternatives to this assertion? At the very least, can I get an explanation of why an assert is correct to which counter-arguments might be considered?
LOL - I remember when you brought this topic up. I didn't have a good answer so I didn't dwell on it. I'm sure I put that in without much thought so I wasn't really in a position to dispute your proposition. In fact, I was inclined to just accept your view without much thought (as clearly you had thought about it much more than I had). This I did in my local copy which has not yet been uploaded to CVS. But it turns out that the issue is moot in any case. Lately I've been spending a little time looking at runtime performance issues and I've concluded that I want to change the implementation of basic_binary_oprimitive to use std::streambuf primitives rather than std::basic_steram read/write. This makes things faster for couple of reasons. I've tested locally the new implementation and it passes all tests. So I want to make the change "official". I do have a couple of pending issues however: a) add a contstructor for binary_?archive which takes a reference to a stream buffer. This would make the creation of a full blown stream unnecessary for binary archives. b) consider where binary i/o (as oppose to text i/o) is specified and where errors in the area are detected. c) update the relevant parts of the documentation. So for now, I would suggest you update your local copy to remove the offending assertion. Robert Ramey P.S. If you're really interested in this and have nothing else to do I would be glad to send you my latest copy of of basic_binary_i/oprimitive.* files RR
But it turns out that the issue is moot in any case. Lately I've been spending a little time looking at runtime performance issues and I've concluded that I want to change the implementation of basic_binary_oprimitive to use std::streambuf primitives rather than std::basic_steram read/write. This makes things faster for couple of reasons.
That all sounds great :) I don't think I need an update before it makes it into the official release; we fixed the problem on our end that was causing this issue to bite us frequently. I look forward to the speed improvements. Austin Bingham
participants (2)
-
Austin Bingham
-
Robert Ramey