Function StaticRingBuffer.tryPushBack
Appends one value without overwriting existing elements.
bool tryPushBack(U)(
auto ref U value
)
if (is(Unqual!U == T) && __traits(compiles, emplace(cast(T*)null, forward!value)));
Parameters
| Name | Description |
|---|---|
| value | value used to construct the new logical back element
Returns false when full. On that path the logical sequence is unchanged
and the container performs no allocation or element construction.
Lvalues use the ordinary core construction path.
For an exact T rvalue whose type defines a D language move constructor,
the move constructor is invoked directly at the final slot address. This
avoids depending on the unresolved rvalue behavior of
core tracked in issue #8. |
Returns
true when a new element was constructed; false when already full.
Failure
When full, the logical sequence and all existing elements are unchanged.
Complexity
O(1).
Allocation
The container itself does not allocate.
Example
StaticRingBuffer!(int, 1) buffer;
assert(buffer .tryPushBack(7));
assert(!buffer .tryPushBack(8));
assert(buffer .front == 7);