On 05/02/2015 01:56 AM, Jonathan M Davis via Digitalmars-d-learn wrote:

> I really don't think that it's reasonable in the general case to expect to
> be able to guarantee that the capacity of a dynamic array won't change.

Yes, it is very different from other languages like C and C++ that talking about this behavior is worth it.

The elements are const, the slice is passed by value, but the reserved capacity disappears:

void foo(const(int)[] b)
{
    b ~= 42;
}

    a.reserve(milllllion);
    assert(a.capacity >= milllllion);

    foo(a);
    assert(a.capacity == 0);    // WAT

Ali

Reply via email to