View source code
							
							
						
								Display the source code in std/experimental/allocator/building_blocks/region.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.
							
						Struct std.experimental.allocator.building_blocks.region.InSituRegion
InSituRegion is a convenient region that carries its storage within itself
(in the form of a statically-sized array).
						
				struct InSituRegion(ulong size, ulong minAlign = platformAlignment)
				;
						
					
				The first template argument is the size of the region and the second is the
needed alignment. Depending on the alignment requested and platform details,
the actual available storage may be smaller than the compile-time parameter. To
make sure that at least n bytes are available in the region, use
InSituRegion!(n + a - 1, a).
Given that the most frequent use of InSituRegion is as a stack allocator, it
allocates starting at the end on systems where stack grows downwards, such that
hot memory is used first.
Methods
| Name | Description | 
|---|---|
| alignedAllocate | As above, but the memory allocated is aligned at abytes. | 
| allocate | Allocates bytesand returns them, ornullif the region cannot
    accommodate the request. For efficiency reasons, ifbytes == 0the
    function returns an empty non-null slice. | 
| allocateAll | Allocates all memory available with this allocator. | 
| available | Nonstandard function that returns the bytes available for allocation. | 
| deallocate | Deallocates b. This works only ifbwas obtained as the last call
    toallocate; otherwise (i.e. another allocation has occurred since) it
    does nothing. This semantics is tricky and thereforedeallocateis
    defined only ifRegionis instantiated withYesas the third template argument. | 
| deallocateAll | Deallocates all memory allocated with this allocator. | 
| expand | Expands an allocated block in place. Expansion will succeed only if the block is the last allocated. | 
| owns | Returns Ternaryifbis the result of a previous allocation,Ternaryotherwise. | 
Aliases
| Name | Description | 
|---|---|
| alignment | An alias for minAlign, which must be a valid alignment (nonzero power
    of 2). The start of the region and all allocation requests will be rounded
    up to a multiple of the alignment. | 
Example
// 128KB region, allocated to x86's cache line
InSituRegion!(128 * 1024, 16) r1;
auto a1 = r1Authors
License
					Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.