Subject: Re: [boost] double_ended - request formal review
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2016-07-26 17:00:09


On 24 July 2016 at 14:44, Benedek Thaler <thalerbenedek_at_[hidden]> wrote:

>
> Thanks for the feedback, Mathias. You are right. This implementation detail
> is a consequence of honoring reserve calls:
>
> devector<int> d;
> d.push_back(1);
> d.reserve_front(100);
> d.reserve_back(100);
>
> The reserve back has to keep the front capacity untouched or it breaks the
> promise of it. This also applies to a series of push_front/pop_backs, for
> example.
>

I think it's pretty serious. Consider:

int n;

devector<int> d;
d.push_back(0);

for(int i=0; i<n; ++i)
{
    d.push_back(i);
    d.pop_front();
}

You end up with ever growing memory consumption, despite the devector only
containing one or two elements at all times.