variadic mixin templates and other stuff

John Chapman johnch_atms at hotmail.com
Fri Apr 20 10:00:09 PDT 2012


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) {}
>     }
>   }
> }
>
> component.d(6): members of template declaration expected
> component.d(6): Declaration expected, not '('
> component.d(10): no identifier for declarator args
> component.d(10): semicolon expected, not ')'
> component.d(10): Declaration expected, not ')'
>
> I am compiling it with dmd v2.058.
>
> Martin

John


More information about the Digitalmars-d-learn mailing list