new T[size] vs .reserve

David d at dav1d.de
Sun Feb 3 02:44:19 PST 2013


Am 02.02.2013 18:40, schrieb Namespace:
> No one said that this is a problem, or? (;
> But why should I generate an array with size 4 if an append of me resize
> it to 5?
That's what reserve is for.

auto bla = new ubate[4];
bla[3] = 1; // valid


ubyte[] bla;
bla.reserve(4);
bla[3] = 1; // invalid


More information about the Digitalmars-d-learn mailing list