
On 8/10/2013 8:59 PM, Rob Stewart wrote:
On Aug 10, 2013, at 8:25 AM, Edward Diener
wrote: On 8/9/2013 9:45 PM, Geoff Shannon wrote:
Particularly, I'm interested in ideas for an appropriate replacement for using char *'s as the data buffers for reading and writing.
std::vector<TYPE> is the C++ way of specifying arrays.
If you do that, don't use resize() and size(). Use reserve() and capacity(), and don't forget to push_back() one element to make &v[0] valid.
I do not follow this. Especially the bit about pushing back an element. Vectors can be empty as I am sure you know and there are still valid.
Having said all that, it really should be wrapped in a buffer class to prevent mistakes. Perhaps that has the makings of a useful Boost addition in its own right.
Do you actually do this in your programming ? To "prevent mistakes" ?
There's also std::array and boost::array.
Sure, but why not use the normal C++ construct.