Boost logo

Boost :

Subject: Re: [boost] [container] static_vector: fixed capacity vector update
From: Adam Wulkiewicz (adam.wulkiewicz_at_[hidden])
Date: 2013-02-01 09:35:56


Krzysztof Czainski wrote:
> 2013/2/1 Adam Wulkiewicz <adam.wulkiewicz_at_[hidden]>
> Furthermore I'd like to share some news.
>>
>> We've decided to slightly change the character of this container and
>> highlight it's connection with array. Therefore we changed it's name
>> to varray (variable-size array). The implementation with "Strategy"
>> template parameter was moved to container_detail namespace. Exposed
>> class takes 2 template parameters, exactly like boost::array does.
>>
>> boost::container::varray<T, N> va;
...
>
>
> For the record, I'd rather the strategy was public. I can imagine using
> static_vector in a few places in the same project with different strategies:
> 1) In most places I'd probably use the default strategy.
> 2) At the time of optimizations I might want to disable all checking
> (asserts) only for one specific use. In practice we don't create separate
> debug/release builds, since we need the debug version to be fast enough
> anyway, and in some places this means disabling asserts.
> 3) In some cases temporary cases I might want logic errors to be thrown, so
> that the crash of an early version of one module doesn't crash the whole
> system.
>
> Also, I prefer the name static_vector, but that's just my personal approach
> - maybe I just got used to it ;-)

After the release of 1.53 when everybody has more free time we should
probably do some voting.

> Although, now that I think of 0-arg emplace_back(), that doesn't
> value-initialize types with a trivial constructor - does vector work like
> this too? If not, then it's a good argument towards the name varray ;-)

Yes, now elements' default ctors aren't called when they're of type with
trivial ctor. This is the case when using:
- varray(n)
- resize(n)
- emplace_back()

This of course may be changed in the future or it may be tweakable with
traits.

Regards,
Adam


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk