Enum member hasSwappableElements
Determines whether the elements of R can be swapped with swap.
enum hasSwappableElements(R)
= is(typeof(swap(R .init .front, R .init .front))) && is(typeof(swap(R .init[0], R .init[0])));
Parameters
Name | Description |
---|---|
R | Range type. |
Returns
true if R has swappable elements, false otherwise.
Example
static struct R1
{
int element;
enum bool empty = false;
ref int front() @nogc nothrow pure @safe
{
return element;
}
alias back = front;
void popFront() @nogc nothrow pure @safe
{
}
alias popBack = popFront;
R1 save() const @nogc nothrow pure @safe
{
return this;
}
}
static assert(hasSwappableElements!R1);
static struct R2
{
int element;
enum bool empty = false;
int front() const @nogc nothrow pure @safe
{
return element;
}
alias back = front;
void popFront() @nogc nothrow pure @safe
{
}
alias popBack = popFront;
R2 save() const @nogc nothrow pure @safe
{
return this;
}
}
static assert(!hasSwappableElements!R2);