Life in the Fast Lane (@nogc blog post)
jmh530 via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Tue Jun 20 09:47:20 PDT 2017
On Tuesday, 20 June 2017 at 15:24:06 UTC, Dukc wrote:
>
> I wasn't skilled enough to make a generic version of this
> trough. And I do not know what happens if @nogc function ends
> up calling gc.
This seems like it only would work if you know that there
wouldn't be any allocations. I don't really know though.
Below is a little more generic:
template gc78f(alias f)
{
void gc78f(T...)(T what) @nogc
{
import std.stdio;
alias fType = void function(T) @nogc;
(cast(fType)&f!T)(what);
}
}
void main() @nogc
{
import std.stdio;
string x = "hello world!";
gc78f!(writeln)(x);
}
More information about the Digitalmars-d-announce
mailing list