singleton

Creates a bidirectional and random-access range with the single element element.

If element is passed by value the resulting range stores it internally. If element is passed by reference, the resulting range keeps only a pointer to the element.

  1. auto singleton(E element)
  2. auto singleton(E element)
    singleton
    (
    E
    )
    (
    return ref E element
    )

Parameters

E

Element type.

element E

Element.

Return Value

Type: auto

A range with one element.

Examples

auto singleChar = singleton('a');

assert(singleChar.length == 1);
assert(singleChar.front == 'a');

singleChar.popFront();
assert(singleChar.empty);

Meta