On Wednesday, 4 February 2026 at 08:45:06 UTC, axricard wrote:
Hello, is there some structure in standard library that acts
like Appender but works also on std.container.array Arrays ?
I'd like to have the capacity of Arrays doubling every time new
memory is allocated.
Appender requires the input to be a dynamic array, which is not
the case for std.container.array Arrays.
To the cost of small run-time overhead one solution is to forward
appending in a custom function, e.g
```d
void append(T)(ref T arr, int elem)
{
arr ~= elem;
static if (is(T == std.container.array.Array!int))
arr.reserve(nextPow2(arr.capacity-1));
writefln("capacity after append: %u", arr.capacity);
}
```