Is it possible to remove elements from a range without losing its capacity?
void main()
{
import std.algorithm.mutation : remove, SwapStrategy;
import std.stdio : writeln;
int[] arr = [1, 2, 3, 2, 4, 2, 5, 2];
assert(arr.length == 8);
assert(arr.capacity == 11);
arr = arr.remove!(SwapStrategy.unstable)(0);
assert(arr.length == 7);
assert(arr.capacity == 0);
}
Here capacity goes to 0. I wish to prevent future reallocations.
This loses the reserved capacity as well:
arr.length--
Thanks