The OpenD Programming Language

array

Convert a narrow autodecoding string to an array type that fully supports random access. This is handled as a special case and always returns an array of dchar

NOTE: This function is never used when autodecoding is turned off.

  1. ForeachType!Range[] array(Range r)
  2. ForeachType!(typeof((*Range).init))[] array(Range r)
  3. CopyTypeQualifiers!(ElementType!String, dchar)[] array(String str)
    array
    (
    String
    )
    (
    scope String str
    )

Parameters

str String

isNarrowString to be converted to an array of dchar

Return Value

Type: CopyTypeQualifiers!(ElementType!String, dchar)[]

a dchar[], const(dchar)[], or immutable(dchar)[] depending on the constness of the input.

Examples

import std.range.primitives : isRandomAccessRange;
import std.traits : isAutodecodableString;

// note that if autodecoding is turned off, `array` will not transcode these.
static if (isAutodecodableString!string)
    assert("Hello D".array == "Hello D"d);
else
    assert("Hello D".array == "Hello D");

static if (isAutodecodableString!wstring)
    assert("Hello D"w.array == "Hello D"d);
else
    assert("Hello D"w.array == "Hello D"w);

static assert(isRandomAccessRange!dstring == true);

Meta