DMD metaprogramming enhancement
Suleyman
sahmi.soulaimane at gmail.com
Thu Apr 25 23:41:32 UTC 2019
Hello everyone,
I am happy to announce that in the next DMD release you will be
able to more freely enjoy your metaprograming experience now that
a long-standing limitation has been lifted.
You can now instantiate local and member templates with local
symbols.
Example:
---
struct S
{
private int _m;
void exec(alias fun)()
{
fun(_m);
}
}
unittest
{
int localVar;
void set(int i)
{
localVar = i;
}
auto obj = S(10);
obj.exec!set(); // no error or warning
assert(localVar == 10);
}
---
I hope you enjoy!
More information about the Digitalmars-d-announce
mailing list