www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16467] New: templated function default argument take into


          Issue ID: 16467
           Summary: templated function default argument take into account
                    when not needed
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: lodovico giaretart.net
                CC: lodovico giaretart.net

T identity(T)(T t = 0)
    return t;

void main()
    int i = identity(); // as expected

    string s = identity("hello");  // error: cannot implictly converto (0)
                                   // of type int to string

I would expect the default value to be completely discarded when the user
supplies a value.

Sep 05 2016