[Issue 16467] New: templated function default argument take into account when not needed
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Sep 5 05:58:36 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16467
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 at puremagic.com
Reporter: lodovico at giaretart.net
CC: lodovico at 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.
--
More information about the Digitalmars-d-bugs
mailing list