Multiple template alias parameters

Rikki Cattermole via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 7 19:03:10 PDT 2015


On 8/05/2015 1:53 p.m., Brian Schott wrote:
> I have some code that automatically wires up control flow based on
> annotations. Use of this code looks something like this:
>
> ```
> import some_package.some_module;
> void main(string[] args) {
>     doMagicStuff!(some_package.some_module)(args);
> }
> ```
>
> All of this works and everything is happy (Except the implementation,
> which is ugly because Phobos is missing a lot of functionality, but
> that's not the topic I'm discussing here).
>
> The problem occurs when I want to register multiple modules to scan for
> functions. The grammar does not allow this syntax:
>
> ```
> template (alias Modules ...) {
> ...
> ```
>
> Any ideas (besides "STRING MIXINS EVERYWHERE")?
>

Can you not use something like this?

import std.stdio;
import std.traits;

void main() {
	func!(std.stdio, std.traits)();		
}


void func(T...)() {
	pragma(msg, T.stringof);
	pragma(msg, fullyQualifiedName!(T[0]));
	
}


More information about the Digitalmars-d-learn mailing list