
I'm using an asio::streambuf to read and write data to a socket. Despite my best efforts, I can't get the streambuf to throw an exception if I consume too much. I'm trying to get it to throw an exception so I can test an error case.
The documentation says streambuf::consume will throw an std::length error if the requested amount to read is greater than the input stream size (http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/reference/basic_str...).
It's a bug in the ducumentation. The function is implemented as follows: void consume(std::size_t n) { if (gptr() + n > pptr()) n = pptr() - gptr(); gbump(static_cast<int>(n)); } So it doesn't throw anything - it just wouldn't allow you to consume more data than available. Actually, it seems to be the correct and consistent behavior.