On Monday, 1 October 2012 at 20:16:09 UTC, Steven Schveighoffer wrote:
We already have that, use templates:

private auto _funimpl(string s) {
/* what was previously in fun(string) */
}

template fun(string s)
{
   enum fun = _funimpl(s);
}

// usage:

fun!("times"); // always executes _funimpl at compile time

Yes, I know. And this helps even more:

template ct(alias expr)
{
     enum ct = expr;
}

auto fun(string s)
{
     ...
}

// usage:

ct!(fun("times"))

But that's still a nuisance.


Reply via email to