Boost logo

Boost :

From: Robert Dailey (rcdailey_at_[hidden])
Date: 2008-07-17 14:20:10


Assume the following code, which I wrote in an attempt to test very
basic functionality of Boost.Iostream:

namespace io = boost::io;

void foo()
{
        std::vector<boost::uint8_t> data;
        io::source<io::iobyte> src( io::chain( io::read_mem( data ) ) );

        io::iobyte rcvbuffer;
        const io::mutable_buffer<io::iobyte> mutbuffer( &rcvbuffer, sizeof(
rcvbuffer ) );
        src.read( mutbuffer );
}

The first issue I have is with mutable_buffer. Notice how it requires
a template argument that *must* be the exact type passed into the
io::source template parameter, in this case io::iobyte. Passing any
other type in here results in lots of compiler errors on MSVC 9.
Basically my biggest issue with this is that I can't pass an "int"
into the mutable_buffer here if I want to read 4 bytes, because the
type passed in must match io::iobyte. In my opinion, mutable_buffer
should accept *any* type and just read in the number of bytes
requested. Without this I fail to see the usefulness of
mutable_buffer.

The second issue has to do with the type of the first parameter in
io::source::read(). Notice it takes a "const mutable_buffer&". Why is
it taking a const mutable_buffer if the buffer is mutable? This seems
conceptually wrong. I would expect it to take a "mutable_buffer&".


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk