Vector.this - multiple declarations
Function Vector.this
Constructs a empty Vector
with allocator a
.
Examples
{
Vector!(int, 6) vec = DefaultAllocator .init;
assert(vec .empty);
}
Function Vector.this
Constructs a empty Vector
this
(
typeof(null) nil
) scope pure nothrow @nogc scope @safe;
Examples
{
Vector!(int, 6) vec = null;
assert(vec .empty);
}
Function Vector.this
Constructs a Vector
object from other vector.
this(Rhs, This)
(
auto scope ref Rhs rhs
) scope scope
if (isVector!Rhs && isConstructable!(Rhs, This) && (isRef!Rhs || !is(immutable(This) == immutable(Rhs))));
Parameters
rhs
other vector of Vector
type.
allocator
optional allocator parameter.
Examples
{
Vector!(int, 6) vec = null;
assert(vec .empty);
}
{
Vector!(int, 6) vec = Vector!(int, 6) .build(1, 2);
assert(vec == [1, 2]);
}
{
auto tmp = Vector!(int, 6) .build(1, 2);
Vector!(int, 6) vec = tmp;
assert(vec == [1, 2]);
}
{
Vector!(int, 6) vec = Vector!(int, 4) .build(1, 2);
assert(vec == [1, 2]);
}
{
auto tmp = Vector!(int, 4) .build(1, 2);
Vector!(int, 6) vec = tmp;
assert(vec == [1, 2]);
}
{
int[3] tmp = [1, 2, 3];
Vector!(int, 6) vec = tmp[];
assert(vec == [1, 2, 3]);
}
{
struct Range{
int i;
bool empty()(){return i == 0;}
int front()(){return i;}
void popFront()(){i -= 1;}
//size_t length(); //no length
}
Vector!(int, 6) vec = Range(3);
assert(vec == [3, 2, 1]);
}
Function Vector.this
Forward constructor.
this(Rhs, This)
(
auto scope ref Rhs rhs,
Forward
) scope scope
if (isVector!Rhs && isConstructable!(Rhs, This));
Function Vector.this
Constructs a Vector
object from range of elements.
this(R, This)
(
R range
) scope scope
if (isBtlInputRange!R && is(ElementEncodingType!R : GetElementType!This));
this(R, This)
(
R range,
Vector . AllocatorType allcoator
) return
if (isBtlInputRange!R && is(ElementEncodingType!R : GetElementType!This));
Parameters
range
input reange of ElementType
elements.
allocator
optional allocator parameter.
Examples
import std .range : iota;
{
Vector!(int, 6) vec = iota(0, 5);
assert(vec == [0, 1, 2, 3, 4]);
}