variadic mixin templates and other stuff
Martin Drasar
drasar at ics.muni.cz
Sat Apr 21 10:54:31 PDT 2012
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
More information about the Digitalmars-d-learn
mailing list