Robert Ramey wrote:
I'm looking at array_sink stream buffer as a possible speed enhancement to binary_oarchive in some cases. My quesion is" What happens when the capacity of the array used for the buffer is exceeded? Is an exception thrown or what?
Sorry I didn't respond sooner. I'm way behind on my Boost stuff. Yes, an exception is thrown. You can see the code at work in boost/iostreams/detail/streambuf/direct_streambuf.hpp.
I've looked through the documentation and don't find exceptions mentioned.
There are no exceptions mentioned in the docs for array_sink, since it doesn't throw exceptions. Your right that the behavior should be documented somewhere, though. I guess I should document stream_buffer::xsputc and stream_buffer::xsputn to explain what happens when a direct sink is exhausted. As far as using array_sink in serialization, if you tell me how you want to use it I may be able to judge whether it is a good idea. It's also possible to design an array sink that can tell you how full it is (see boost/iostreams/detail/counted_array.hpp) but it's not as efficient, since it uses a read/write interface instead of simply delivering a fixed array of characters to std::streambuf.
Robert Ramey
-- Jonathan Turkanis www.kangaroologic.com