View source code
							
							
						
								Display the source code in object.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla 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 using
								local clone.
							
						Function object.reserve
Reserves capacity for a slice. The capacity is the size that the slice can grow to before the underlying array must be reallocated or extended.
						
				size_t reserve(T)
				(
				
				  ref T[] arr,
				
				  size_t newcapacity
				
				) pure nothrow @trusted;
						
					
				Returns
The new capacity of the array (which may be larger than the requested capacity).
Example
//Static array slice: no capacity. Reserve relocates.
int[4] sarray = [1, 2, 3, 4];
int[]  slice  = sarray[];
auto u = sliceAuthors
Walter Bright, Sean Kelly
License
					Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.