Is it possible to use tokens as template parameters?
Daniel N
no at public.email
Sun Aug 15 08:40:58 UTC 2021
On Sunday, 15 August 2021 at 05:47:34 UTC, rempas wrote:
>> [...]
>
> Makes sense. I also thought that Rust's macro_rules! were cool
> but I understand your point. Thanks a lot!
opDispatch can create strings, which can either be directly mixed
in, or the generated string can be send to mixin templates.
```d
import std;
static struct Yay
{
string opDispatch(string name, T...)(T vals)
{
return q{
auto %s = 777;
}.format(name);
}
}
enum yay=Yay();
void main()
{
mixin(yay.magic);
magic.writeln;
}
```
More information about the Digitalmars-d
mailing list