Setting defaults to variadic template args

Andrej Mitrovic andrej.mitrovich at gmail.com
Tue Oct 2 06:24:59 PDT 2012


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


More information about the Digitalmars-d mailing list