This does not work because 'range_t r (cursor, end)' is a range of buffers, not a range of characters. Thus, you are comparing a list of buffer pointers with each character in LINE_END_MARK.
If a crash occurs in release mode under win32, because on Windows you end up deleting the reference to the null pointer that causes the crash.
boost asio has this concept of multiple buffers, but is currently not used. If you look at the implementation, if only it actually uses "const_buffers_1" or "mutable_buffers_1", which is basically a list of 1 buffer.
I assume that you want to compare the contents of the buffer, not the list of buffer ranges.
So you want to do something like:
typedef boost::iterator_range<const char*> range_t; range_t r(boost::asio::buffer_cast<const char*>(_buf.data()), boost::asio::buffer_cast<const char*>(_buf.data()) + boost::asio::buffer_size(_buf.data())); if(!boost::ends_with(r, LINE_END_MARK)) return 0; return 1;
Shane powell
source share