Boost logo

Boost :

Subject: Re: [boost] [Interprocess] Named pipe interface proposal
From: Rob Stewart (robertstewart_at_[hidden])
Date: 2013-08-12 05:02:28

On Aug 11, 2013, at 8:56 PM, Marshall Clow <mclow.lists_at_[hidden]> wrote:

> On Aug 11, 2013, at 12:39 PM, Rob Stewart <robertstewart_at_[hidden]> wrote:
>> On Aug 11, 2013, at 9:50 AM, Edward Diener <eldiener_at_[hidden]> wrote:
>>> On 8/10/2013 8:59 PM, Rob Stewart wrote:
>>>> On Aug 10, 2013, at 8:25 AM, Edward Diener <eldiener_at_[hidden]> wrote:
>>>>> 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.
>> Accessing an element of an empty vector is undefined behavior. Calling resize() to reserve space also causes elements to be initialized, which is often not needed when calling an API that indicates the number of bytes written.
>> What I often do is the following:
>> std::vector<char> v;
>> v.reserve(1024);
>> v.push_back(0);
>> read(&v[0], v.capacity());
>> That can be simplified by a wrapper class.
> Rob --
> Could you have meant "resize()" instead of "reserve()" here?

No. See my reply to Edward.


(Sent from my portable computation engine)

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