DMD metaprogramming enhancement

Greatsam4sure greatsam4sure at gmail.com
Fri Apr 26 14:36:33 UTC 2019


On Thursday, 25 April 2019 at 23:41:32 UTC, Suleyman wrote:
> 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!


Thanks a lot. It is really refreshing to know this has been fixed.






More information about the Digitalmars-d-announce mailing list