why no statements inside mixin teplates?
via Digitalmars-d
digitalmars-d at puremagic.com
Thu May 11 17:20:13 PDT 2017
Is there a rational behind not allowing statements inside mixin
templates? I know mixin does accept code containing statements,
but using mixin is much uglier. so I was wondering.
example use case:
//---------------------------------
int compute(string)
{
return 1;
}
mixin template testBoilerPlate(alias arg, alias expected)
{
{
import std.format : format;
auto got = compute(arg);
assert(got == expected, "expected %s got
%s".format(expected, got));
}
}
unittest
{
mixin testBoilerPlate("12345", 1);
mixin testBoilerPlate("00" ~ "0", 2 - 1);
}
//--------------------------------
More information about the Digitalmars-d
mailing list