Implicit conversion from null in custom type

Andrea Fontana via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 28 06:12:17 PDT 2015


void fun(typeof(null)) { }

?


On Thursday, 28 May 2015 at 13:06:27 UTC, Vladimir Panteleev 
wrote:
> On Thursday, 28 May 2015 at 12:37:52 UTC, Andrea Fontana wrote:
>> What's the problem with ctor taking typeof(null)?
>> I've just used it, maybe I missed something?
>
> It doesn't work:
>
> ////////// test.d /////////
> struct S
> {
>     this(typeof(null) p) {}
> }
>
> void fun(S s) {}
> void main() { fun(null); }
> ///////////////////////////
>
> test.d(7): Error: function test.fun (S s) is not callable using 
> argument types (typeof(null))



More information about the Digitalmars-d-learn mailing list