On Saturday, 28 July 2012 at 02:33:54 UTC, Jonathan M Davis wrote:
@property auto save()
{
    import std.conv;
    alias typeof((*_range).save) S;
static assert(isForwardRange!S, S.stringof ~ " is not a forward range.");

    @trusted
    {
        auto mem = new void[S.sizeof];`
        emplace!S(mem, cast(S)(*_range).save);`
        return RefRange!S(cast(S*)mem.ptr);
    }
}

That is _way_ cleaner.

But unfortunately wrong – you call S.save in the @trusted block… ;)

David

Reply via email to