Function Vector.emplaceBack
Appends a new element to the end of the container. The element is constructed through emplace
.
void emplaceBack(Args...)
(
auto ref Args args
) scope;
Parameters
args
arguments to forward to the constructor of the element.
Examples
{
auto vec = Vector!(int, 6) .build(1, 2, 3);
vec .emplaceBack(42);
assert(vec == [1, 2, 3, 42]);
vec .emplaceBack();
assert(vec == [1, 2, 3, 42, 0]);
}
{
static struct Foo{
int i;
string str;
}
auto vec = Vector!(Foo, 6) .build(Foo(1, "A"));
vec .emplaceBack(2, "B");
assert(vec == only(Foo(1, "A"), Foo(2, "B")));
}