digitalmars.D.bugs - [Issue 14736] New: Function Default Parameters Are Lost
- via Digitalmars-d-bugs (54/54) Jun 25 2015 https://issues.dlang.org/show_bug.cgi?id=14736
https://issues.dlang.org/show_bug.cgi?id=14736 Issue ID: 14736 Summary: Function Default Parameters Are Lost Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: paul.d.anderson comcast.net I'm trying to pass a function pointer while keeping the default parameter values intact. Given the following: import std.traits; import std.stdio; int foo(int a, int b = 1) { return a; } alias FOOP = int function(int, int = 1); struct ST(POOF) { FOOP fctn; this(POOF fctn) { this.fctn = fctn; } void details() { alias PDVA = ParameterDefaultValueTuple!fctn; writefln("typeid(PDVA[0]) = %s", typeid(PDVA[0])); writefln("typeid(PDVA[1]) = %s", typeid(PDVA[1])); } } void main() { FOOP fp = &foo; auto st = ST!FOOP(fp); st.details; } The default parameter value types are void, int: a has no default and b has an int value as its default. If I change line 14 from FOOP fctn; to POOF fctn; The default parameter value types are void, void. In other words the default value for b is no longer there. Why doesn't invoking the template (ST!FOOP) replace POOF in line 14 with FOOP? wrong. --
Jun 25 2015