|
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
-- Boris Kolpackov, Code Synthesis http://codesynthesis.com/~boris/blog Compiler-based ORM system for C++ http://codesynthesis.com/products/odb Open-source XML data binding for C++ http://codesynthesis.com/products/xsd XML data binding for embedded systems http://codesynthesis.com/products/xsde
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk