Enum member isOutputRange
Determines whether R is an output range for the elemens of type E.
enum isOutputRange(R, E)
= true;
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:
Code | Scenario |
---|---|
r(e) | R defines opCall for E. |
r.front = e | R is an input range with assignable elements of type E. |
Output ranges don't have element type (so ElementType returns void when applied to an output range). It is because an output range can support puting differently typed elements into it.
Parameters
Name | Description |
---|---|
R | The type to be tested. |
E | Element type should be tested for. |
Returns
true if R is an output range for the elements of the type E, false otherwise.
See Also
put.
Example
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));