View source code
Display the source code in std/experimental/allocator/typed.d from which thispage was generated on github.
Report a bug
If you spot a problem with this page, click here to create aBugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinglocal clone.
Function std.experimental.allocator.typed.TypedAllocator.shrinkArray
Shrinks an array by delta elements using allocatorFor!(T[]).
bool shrinkArray(T)(
ref T[] arr,
size_t delta
);
If arr, does nothing and returns false. Otherwise,
destroys the last arr elements in the array and then
reallocates the array's buffer. If reallocation fails, fills the array with
default-initialized data.
Parameters
| Name | Description |
|---|---|
| T | element type of the array being created |
| arr | a reference to the array being shrunk |
| delta | number of elements to remove (upon success the new length of
arr is arr) |
Returns
true upon success, false if memory could not be reallocated. In the
latter case arr[$ - delta .. $] is left with default-initialized
elements.
Throws
The first two overloads throw only if the used allocator's primitives do. The overloads that involve copy initialization deallocate memory and propagate the exception if the copy operation throws.
Authors
License
Copyright © 1999-2026 by the D Language Foundation | Page generated by ddox.