Constructs a RefAppender with a given array reference. This does not copy the data. If the array has a larger capacity as determined by arr.capacity, it will be used by the appender.
Wraps remaining Appender methods such as put.
Appends rhs to the managed array.
Returns the capacity of the array (the maximum number of elements the managed array can accommodate before triggering a reallocation). If any appending will reallocate, capacity returns 0.
The array type to simulate
int[] a = [1, 2]; auto app2 = appender(&a); assert(app2[] == [1, 2]); assert(a == [1, 2]); app2 ~= 3; assert(app2.length == 3); app2 ~= [4, 5, 6]; assert(app2[] == [1, 2, 3, 4, 5, 6]); assert(a == [1, 2, 3, 4, 5, 6]); app2.reserve(5); assert(app2.capacity >= 5);
A version of Appender that can update an array in-place. It forwards all calls to an underlying appender implementation. Any calls made to the appender also update the pointer to the original array passed in.
Tip: Use the arrayPtr overload of appender for construction with type-inference.