https://issues.dlang.org/show_bug.cgi?id=17914
--- Comment #9 from Martin Nowak <c...@dawg.eu> --- If scoped isn't enough, you could use automem (~master or the next release) for ref-counted classes. http://code.dlang.org/packages/automem import automem.ref_counted; auto gen = RefCounted!(Generator!int)({yield(42);}); writeln(gen.front); gen.popFront; assert(gen.empty); --