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);
}