View source code Display the source code in std/array.d from which this page was generated on github. Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.

std.array.array - multiple declarations

Function array

Allocates an array and initializes it with copies of the elements of range r.

Narrow strings are handled as a special case in an overload.

Prototype

ForeachType!Range[] array(Range)(
  Range r
)
if (isIterable!Range && !isNarrowString!Range && !isInfinite!Range);

Parameters

NameDescription
r range (or aggregate with opApply function) whose elements are copied into the allocated array

Returns

allocated and initialized array

Example

auto a = array([1, 2, 3, 4, 5][]);
assert(a == [ 1, 2, 3, 4, 5 ]);

Function array

Convert a narrow string to an array type that fully supports random access. This is handled as a special case and always returns a dchar[], const(dchar)[], or immutable(dchar)[] depending on the constness of the input.

Prototype

ElementType!String[] array(String)(
  String str
)
if (isNarrowString!String);

Authors

Andrei Alexandrescu and Jonathan M Davis

License

Boost License 1.0.

Comments