Setting defaults to variadic template args
Manu
turkeyman at gmail.com
Tue Oct 2 07:11:54 PDT 2012
On 2 October 2012 16:45, Manu <turkeyman at gmail.com> wrote:
> On 2 October 2012 16:24, Andrej Mitrovic <andrej.mitrovich at gmail.com>wrote:
>
>> On 10/2/12, Manu <turkeyman at gmail.com> wrote:
>> > Does anyone have any clever tricks that will work in this scenario? Some
>> > magic tuple syntax?
>>
>> Without resorting to helper templates I only know of using this internal
>> trick:
>>
>> struct Event(Args...)
>> {
>> static if (Args.length)
>> alias Args T;
>> else
>> alias TypeTuple!(int, float) T;
>>
>> void F(T t) { }
>> }
>>
>> Also there's a somewhat related bug but for variadic template
>> functions with default arguments:
>> http://d.puremagic.com/issues/show_bug.cgi?id=8687
>>
>
> I think this is fine for my needs. Thanks!
>
Actually, this leaves a problem...
Distinction between:
Event x; // using defaults
and
Event!() x; // explicitly selecting none (which would fall back to the
defaults)
Is such a distinction possible? I presume not...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20121002/4289fe72/attachment.html>
More information about the Digitalmars-d
mailing list