Boost logo

Boost :

From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2005-12-27 21:16:23

Hi Mats,

--- Mats Nilsson <mats.nilsson_at_[hidden]> wrote:
> Just a question asking to clarify the use of "const
> Mutable_Buffers &mutable_buffers" in the calls to some of the
> functions, e.g stream_socket::receive(const Mutable_Buffers
> &buffers, message_flags flags).
> To me, this is not logical, since I'd expect a receive
> function to actually modify the stuff I send into it, and the
> const qualifier doesn't seem to allow this.

The constness is shallow. In general, the *_buffer classes do as
the pairs do. That is, the const_buffer class behaves the same
as pair<const void*, size_t>, and mutable_buffer class as
pair<void*, size_t>.

The buffers parameter is a const& so that temporaries and
"heavy" objects (e.g. std::vector<mutable_buffer>) can be passed
through efficiently.

> If it needs to be this way, you might want to explicitly
> explain this design choice somewhere close to where it is
> used.

No problem.

> Also the reference documentation for asio::mutable_buffer
> seems to have a copy-paste bug; its detailed description
> includes "The const_buffer class provides ...", or am I
> missing something?

Fixed, thanks.


Boost list run by bdawes at, gregod at, cpdaniel at, john at