String.reserve

Reserves size bytes for the string.

If size is less than or equal to the $(D_PSYMBOL capacity), the function call does not cause a reallocation and the string capacity is not affected.

struct String
@nogc nothrow pure @trusted
void
reserve
(
const size_t size
)

Parameters

size size_t

Desired size in bytes.

Examples

String s;
assert(s.capacity == 0);

s.reserve(3);
assert(s.capacity == 3);

s.reserve(3);
assert(s.capacity == 3);

s.reserve(1);
assert(s.capacity == 3);

Meta