StringMap.assumeSafeAppend

Assume that it is safe to append to this associative array. Appends made to this associative array after calling this function may append in place, even if the array was a slice of a larger array to begin with. Use this only when it is certain there are no elements in use beyond the associative array in the memory block. If there are, those elements will be overwritten by appending to this associative array.

Warning: Calling this function, and then using references to data located after the given associative array results in undefined behavior.

struct StringMap(T, U = uint)
ref @system nothrow inout return
inout(typeof(this))
assumeSafeAppend
()
()
if (
isMutable!T &&
!__traits(hasMember, T, "opPostMove")
&&
__traits(isUnsigned, U)
)

Return Value

Type: inout(typeof(this))

The input is returned.

Examples

StringMap!double map;
map["c"] = 4.0;
map["a"] = 3.0;
assert(map.capacity >= 2);
map.remove("c");
assert(map.capacity == 0);
map.assumeSafeAppend;
assert(map.capacity >= 2);

Meta