Templates with scope

Sönke Ludwig sludwig at outerproduct.org
Wed Jul 21 09:06:52 UTC 2021

Am 21.07.2021 um 09:16 schrieb bauss:
> Is there a way to make this logic work without using a mixin template.
> I'd prefer if using a plain template was possible, rather than using a 
> mixin template, because it introduces some extra boilerplate.

The symbol name is not available in the scope of the template, so that 
the `mixin(symbol.stringof)` doesn't work, but you can simply use the 
alias directly:

     template CanCompile(alias symbol)
         enum CanCompile = __traits(compiles, { symbol = 10; });

More information about the Digitalmars-d mailing list