Enum member hasLvalueElements
Determines whether R provides access to its elements by reference.
enum hasLvalueElements(R)
= is(typeof(refDg(R .init .front))) && is(typeof(refDg(R .init[0])));
Parameters
Name | Description |
---|---|
R | Range type. |
Returns
true if R has lvalue elements, false otherwise.
Example
static struct R1
{
enum bool empty = false;
int front() @nogc nothrow pure @safe
{
return 5;
}
void popFront() @nogc nothrow pure @safe
{
}
}
static assert(!hasLvalueElements!R1);
static struct R2
{
int element;
enum bool empty = false;
ref const(int) front() const @nogc nothrow pure @safe
{
return element;
}
void popFront() @nogc nothrow pure @safe
{
}
ref const(int) opIndex(size_t) const @nogc nothrow pure @safe
{
return element;
}
}
static assert(hasLvalueElements!R2);