[Asio] streambuf exceptions

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...).
But in my test program, this did not happen. Do I need to enable exception
throwing somehow? Or is streambuf working as intended and not supposed to
throw an exception?
Here is my test program:
#include <iostream>
#include

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.
participants (2)
-
Dylan Klomparens
-
Igor R