@nogc formattedWrite
Ilya Yaroshenko
ilyayaroshenko at gmail.com
Mon Oct 9 10:50:33 UTC 2017
On Saturday, 7 October 2017 at 18:14:00 UTC, Nordlöw wrote:
> Is it currently possible to somehow do @nogc formatted output
> to string?
>
> I'm currently using my `pure @nogc nothrow` array-container
> `CopyableArray` as
>
> @safe pure /*TODO nothrow @nogc*/ unittest
> {
> import std.format : formattedWrite;
> const x = "42";
> alias A = CopyableArray!(char);
> A a;
> a.formattedWrite!("x : %s")(x);
> assert(a == "x : 42");
> }
>
> but I can't tag the unittest as `nothrow @nogc` because of the
> call to `formattedWrite`. Is this because `formattedWrite`
> internally uses the GC for buffer allocations or because it may
> throw?
>
> It would be nice to be able to formatted output in -betterC...
Phobos code is not @nogc (can be fixed), but it will not nothrow.
PRs with @nogc formatting functionality are welcome in Mir
Algorithm.
Cheers,
Ilya
More information about the Digitalmars-d-learn
mailing list