isOutputRange

Determines whether R is an output range for the elemens of type E.

If R is an output range for the elements of type E if an element e of type E can be put into the range instance r in one of the following ways:

CodeScenario
r(e)R defines opCall for E.
r.front = eR is an input range with assignable elements of type E.

Output ranges don't have element type (so $(D_PSYMBOL ElementType) returns $(D_KEYWORD void) when applied to an output range). It is because an output range can support puting differently typed elements into it.

Members

Aliases

ET
alias ET = ElementType!E
Undocumented in source.

Variables

isOutputRange
enum bool isOutputRange;
Undocumented in source.
isOutputRange
enum bool isOutputRange;
Undocumented in source.
isOutputRange
enum bool isOutputRange;
Undocumented in source.

Parameters

R

The type to be tested.

E

Element type should be tested for.

Return Value

$(D_KEYWORD true) if R is an output range for the elements of the type E, $(D_KEYWORD false) otherwise.

Examples

static struct R1
{
    void opCall(int) @nogc nothrow pure @safe
    {
    }
}
static assert(isOutputRange!(R1, int));

static struct R2
{
    int value;

    void popFront() @nogc nothrow pure @safe
    {
    }

    ref int front() @nogc nothrow pure @safe
    {
        return value;
    }

    bool empty() const @nogc nothrow pure @safe
    {
        return true;
    }
}
static assert(isOutputRange!(R2, int));

static struct R3
{
    void popFront() @nogc nothrow pure @safe
    {
    }

    int front() @nogc nothrow pure @safe
    {
        return 0;
    }

    bool empty() const @nogc nothrow pure @safe
    {
        return true;
    }
}
static assert(!isOutputRange!(R3, int));

See Also

$(D_PSYMBOL put).

Meta