Boost logo

Boost :

From: Jeremy Maitin-Shepard (jbms_at_[hidden])
Date: 2005-08-18 18:58:49

"Thorsten Ottosen" <nesotto_at_[hidden]> writes:

> "Jeremy Maitin-Shepard" <jbms_at_[hidden]> wrote in message
>> "Thorsten Ottosen" <nesotto_at_[hidden]> writes:
>> >> reason to use std::vector. I do not think the additional safety
>> >> provided is worth the cost of this overhead.
>> > doesn't the overhead depend on the amount of data sent?
>> I suppose that is true. If a vector must be passed to the receive
>> function, then programs using this library will either have to use an
>> std::vector for any buffers used for receive, which is annoying for
>> users that would prefer to use a different data structure for a buffer,
>> and has the additional overhead of a dynamically allocated buffer and
>> the additional storage std::vecetor requires for the size, capacity, etc.

> the space required by vector is 3 words. that is not much for many
> purposes.

Well, I agree it is not a large amount of overhead given certain usage
patterns. But note that requiring either a vector or a static array
prevents reading directly into a memory-mapped region. It is also not
nearly as convenient to directly read a structure or non-char type
without the memory-range interface.

>> some additional safety, while introducing a more complex and less
>> generic interface.

> how is passing 1 agument instead of two going to be more complex?
> is it because you can't get the size wrong? :-)

Well, more complex in the sense that the operation itself just needs a
memory range, but with this interface you can't just pass it a memory
range, but rather must pass it something that consists of more than just
a memory range. I suppose complex is not a great term to use.


> right. so by passing char (&)[N] you can check that the
> size argument is not too big. with void* you're just lost.

Well, I admit this safety is rather handy, but I doubt this interface
would be used much, since it is not very common to pass arrays around as
a reference to static-sized array, so even if the user has a
static-sized array, it might not be of the appropriate type at the point
where receive/read is called.

Jeremy Maitin-Shepard

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