function pointer and default argument

Jonathan M Davis jmdavisProg at gmx.com
Wed Aug 22 13:33:33 PDT 2012


On Wednesday, August 22, 2012 11:51:45 Ellery Newcomer wrote:
> hey.
> 
> is this valid code?
> 
> void func1(int i, double j = 1.0) {
> }
> 
> void main() {
> auto fn = &func1;
> func1(1); //dmd: ok
> fn(1); // dmd: not ok
> }

Default arguments are not part of the type. This behavior is very much on 
purpose.

http://d.puremagic.com/issues/show_bug.cgi?id=3866
http://d.puremagic.com/issues/show_bug.cgi?id=8402
http://d.puremagic.com/issues/show_bug.cgi?id=8515

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list