
Hi Robert, "Stewart, Robert" <Robert.Stewart@sig.com> writes:
No you wouldn't. As I showed in the portion of my reply that you cut, if your packet owns its data, then it would have a container of that data.
Yes, which would involve having a data member of the std::vector<char> type. Let me put it this way: if I want *both* to own the data and have a convenient interface for it, I would have to have two members, as I showed in my original code. Is that not so?
When you want performance, you don't want to copy data. Your model requires that the data be copied.
If you want unsafe sharing semantics, you can always pass/store references to the buffer instead of making a copy. For example: class packet { packet (const buffer& p): payload_ (p) {} buffer& payload_; }; You also have the option of safe sharing with something like shared_ptr. 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