Function frontInserter
If container is a container with insertFront
-support,
frontInserter returns an output range that puts the elements
into the container with insertFront
.
auto frontInserter(Container)
(
scope ref return Container container
)
if (hasMember!(Container, "insertFront"));
The resulting output range supports all types insertFront
supports.
The range keeps a reference to the container passed to it, it doesn't use any other storage. So there is no method to get the written data out of the range - the container passed to frontInserter contains that data and can be used directly after all operations on the output range are completed. It also means that the result range is not allowed to outlive its container.
Parameters
Name | Description |
---|---|
Container | Container type. |
container | Container used as an output range. |
Returns
insertFront
-based output range.
Example
static struct Container
{
int element;
void insertFront(int element)
{
this .element = element;
}
}
Container container;
frontInserter(container)(5);
assert(container .element == 5);