Function List.emplaceFront

Appends a new element to the begin of the list. The element is constructed through emplace.

void emplaceFront(Args...) (
  auto ref Args args
) scope;

Parameters

args arguments to forward to the constructor of the element.

Examples

{
    auto list = List!(int).build(1, 2, 3);

    list.emplaceFront(42);
    assert(list == [42, 1, 2, 3]);

    list.emplaceFront();
    assert(list == [0, 42, 1, 2, 3]);
}

{
    static struct Foo{
        int i;
        string str;
    }

    auto list = List!(Foo).build(Foo(1, "A"));

    list.emplaceFront(2, "B");
    assert(list == only(Foo(2, "B"), Foo(1, "A")));
}