How to create compile-time container?

Andrey Zherikov andrey.zherikov at gmail.com
Tue Sep 1 19:09:45 UTC 2020


On Tuesday, 1 September 2020 at 18:57:30 UTC, Steven 
Schveighoffer wrote:
> string overrideState(string s)
> {
>    // work your magic here, it's normal D code!
> }
>
> void foo(string s)()
> {
>    mixin(overrideState(s));
> }

Unfortunately this won't work if there is a function 'bar' in 
different module that calls 'foo':

void bar()
{
    foo!"bar";
}

void foo(string s)()
{
   mixin(overrideState(s));

   ...
   mixin("bar()");     // just for illustration
}



More information about the Digitalmars-d-learn mailing list