Implicit conversion from null in custom type

Andrea Fontana via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 28 05:37:50 PDT 2015


What's the problem with ctor taking typeof(null)?
I've just used it, maybe I missed something?

On Thursday, 28 May 2015 at 11:19:39 UTC, Vladimir Panteleev 
wrote:
> I'm trying to write a type which (to some extent) emulates 
> built-in AAs.
>
> One thing I'm having trouble with is null function parameters:
>
> void fun(S s) {}
> void main() { fun(null); }
>
> How can S implement implicit conversion from null?
>
> I've already tried "alias this" and a constructor taking 
> typeof(null).



More information about the Digitalmars-d-learn mailing list