[Issue 2803] template + default argument = doesn't work

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 5 17:00:28 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2803


smjg at iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg at iname.com
         OS/Version|Linux                       |All




------- Comment #1 from smjg at iname.com  2009-04-05 19:00 -------
I'm not sure that this is supposed to work.  It would appear that the process
of binding template parameters to arguments happens strictly before that of
applying default arguments.  Moreover, even if U is given, if it's anything but
S then it triggers a type mismatch on the default argument.

It would appear that you need two templates

void fun(T)(T t)
{
    fun(t, getS());
}

void fun(T, U)(T t, U u)
{
}


-- 



More information about the Digitalmars-d-bugs mailing list