hasSwappableElements

Determines whether the elements of $(D_PSYMBOL R) can be swapped with $(D_PSYMBOL swap).

Members

Variables

hasSwappableElements
enum bool hasSwappableElements;
Undocumented in source.
hasSwappableElements
enum bool hasSwappableElements;
Undocumented in source.
hasSwappableElements
enum bool hasSwappableElements;
Undocumented in source.

Parameters

R

Range type.

Return Value

$(D_KEYWORD true) if R has swappable elements, $(D_KEYWORD false) otherwise.

Examples

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);

Meta