On 20.4.2012 19:00, John Chapman wrote: > On Friday, 20 April 2012 at 14:57:03 UTC, Martin Drasar wrote: >> On 20.4.2012 16:09, Timon Gehr wrote: >> >> I tried but it still refuses to compile: >> >> string interfaceGuid(string ifaceName) >> { >> return ifaceName ~ "Guid"; >> } >> >> mixin template EXPOSE_INTERFACES(T...)(T args) > > Try this: > > mixin template EXPOSE_INTERFACES(T...) > >> { >> void QueryInterface(ref IComponent comp, string guid) >> { >> foreach (arg; args) > > and this: > > foreach (arg; T) > >> { >> if (mixin(interfaceGuid(arg)) == guid) {} >> } >> } >> } >>
Hi John, thanks very much. That did the trick. I am still wondering - why my previous code did not work? This is the syntax I have adopted from variadic functions in TDPL. Why does it work with functions and not mixin templates? Thanks, Martin