Some @nogc text conversion in Phobos?
bearophile via Digitalmars-d
digitalmars-d at puremagic.com
Sat May 31 11:55:34 PDT 2014
Dicebot:
> Benefits: no arbitrary message length limit, no string
> construction unless toString is actually called.
A nothrow @nogc function like the bufferText I've suggested is
also useful in situations like this (currently this can't
compile):
struct Foo {
int[3] data;
ref int opIndex(in size_t i) pure nothrow @safe @nogc
in {
import std.string: format;
assert(i < data.length,
format("opIndex, %d >= %d", i, data.length));
} body {
return data[i];
}
}
void main() {
Foo f;
auto r = f[10];
}
Bye,
bearophile
More information about the Digitalmars-d
mailing list