d的this出域

import std.format;
import std.stdio;

struct SomeId
{
    invariant
    {
    }

    ref SomeId write(string fmt, string value)return 
    {
        return this;
    }

    ref SomeId write(string value) return 
    {
        return write("%s", value);
    }

    void toString(scope void delegate(const(char)[]) sink)
    {
        write("asdf");
    }
}

void main()
{
    SomeId d;
    auto e=format!"ID: %s"(d);
    string b;
    d.write(b);
    writeln("asdf",e,b);
}

要加上return.

posted @ 2022-11-19 13:48  zjh6  阅读(23)  评论(0)    收藏  举报  来源