destroyAll

Destroys all elements in the range.

This function has effect only if the element type of Range has an elaborate destructor, i.e. it is a $(D_PSYMBOL struct) with an explicit or generated by the compiler destructor.

void
destroyAll
(
Range
)
(
Range range
)
if (
isInputRange!Range &&
hasLvalueElements!Range
)

Parameters

Range

Input range type.

range Range

Input range.

Examples

static struct WithDtor
{
    private size_t* counter;
    ~this() @nogc nothrow pure
    {
        if (this.counter !is null)
        {
            ++(*this.counter);
        }
    }
}

size_t counter;
WithDtor[2] withDtor = [WithDtor(&counter), WithDtor(&counter)];

destroyAll(withDtor[]);

assert(counter == 2);

Meta