Boost logo

Boost :

Subject: Re: [boost] Interest in a simple buffer abstraction?
From: Boris Kolpackov (boris_at_[hidden])
Date: 2011-01-28 02:14:52

Hi Robert,

"Stewart, Robert" <Robert.Stewart_at_[hidden]> writes:

> > std::vector<char> data_store_;
> > boost::buffer data_;
> Why would you have both?

Because I want the packet to own the data and to be able to access
it using a natural interface. With your approach I would have to
write gratuitous code like this.

> which requires that some other code create a std::vector<char> or
> other container for the packet to use.

This goes down the slippery slop of someone else owning the memory
and making sure it is not gone while other objects still reference
it. If that's the functionality you want, then why bother with the
buffer class at all? Simply store a pair: const void*, size_t; it
will be just as convenient.


Boris Kolpackov, Code Synthesis
Compiler-based ORM system for C++
Open-source XML data binding for C++
XML data binding for embedded systems

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