put

Puts e into the range.

$(D_PSYMBOL 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 $(D_PSYMBOL 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.

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

Parameters

R

Target range type.

E

Source element type.

range R

Target range.

e E

Source element.

Examples

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

put(slice, 2);
assert(actual == [2, 0]);
static struct OpCall
{
    int e;

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

See Also

$(D_PSYMBOL isOutputRange).

Meta