frontInserter

If container is a container with insertFront-support, $(D_PSYMBOL frontInserter) returns an output range that puts the elements into the container with 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 $(D_PSYMBOL 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.

frontInserter
(
Container
)
(
return scope ref Container container
)
if (
hasMember!(Container, "insertFront")
)

Parameters

Container

Container type.

container Container

Container used as an output range.

Return Value

Type: auto

insertFront-based output range.

Examples

static struct Container
{
    int element;

    void insertFront(int element)
    {
        this.element = element;
    }
}
Container container;
frontInserter(container)(5);

assert(container.element == 5);

Meta