Function put

Puts e into the range.

void put(R, E) (
  ref R range,
  auto ref E e
);

R should be an output range for E, i.e. at least one of the following conditions should met:

  1. e can be put into range using range(e)
  2. e can be assigned to range.front

The method to put e into range is chosen based on the order specified above.

If E is an input range and R is an output range for its elements as well, use tanya.algorithm.mutation.copy instead.

range is advanced after putting an element into it if it is an input range that doesn't define a put-method.

Parameters

NameDescription
R Target range type.
E Source element type.
range Target range.
e Source element.

See Also

isOutputRange.

Example

int[2] actual;
auto slice = actual[];

put(slice, 2);
assert(actual == [2, 0]);

Example

static struct OpCall
{
    int e;

    void opCall(int e)
    {
        this.e = e;
    }
}
OpCall oc;
put(oc, 2);
assert(oc.e == 2);