Reading the documentation on RefCounted I get the impression that the following can lead to memory errors. Could someone explain exactly how that could happen? I suppose that problem would be the call something to do with front?

```
private struct RefCountedRangeReturnType(R)
{
    import std.typecons : RefCounted;
    private RefCounted!R r;
    auto empty() { return r.refCountedPayload.empty; }
    auto front() { return r.refCountedPayload.front; }
    void popFront() { r.refCountedPayload.popFront; }
auto save() { return typeof(this)(RefCounted!R(r.refCountedPayload.save)); }
}

auto refCountedRange(R)(R r)
{
    import std.typecons : RefCounted;
    return  RefCountedRangeReturnType!R(RefCounted!R(r));
}
```

Reply via email to