Null argument and function resolution

2015-05-27 Thread Andrea Fontana via Digitalmars-d-learn
Check this example: http://dpaste.dzfl.pl/53f85bae4382 Calling with null, both c-tor match. Is there a way to solve this? Something like: this(in ubyte* data) if( ??? ) { } Andrea

Re: Null argument and function resolution

2015-05-27 Thread Adam D. Ruppe via Digitalmars-d-learn
Two options: 1) add an overload that takes typeof(null) this(typeof(null)) { /* handles the null literal specially */ } 2) Cast null to a specific type when making it: new YourClass(cast(ubyte*) null);

Re: Null argument and function resolution

2015-05-27 Thread Andrea Fontana via Digitalmars-d-learn
The first answer is the one I was looking for. Very useful. You should add to next this week in d tips. On Wednesday, 27 May 2015 at 14:09:48 UTC, Adam D. Ruppe wrote: Two options: 1) add an overload that takes typeof(null) this(typeof(null)) { /* handles the null literal specially */ } 2)

Re: Null argument and function resolution

2015-05-27 Thread ketmar via Digitalmars-d-learn
On Wed, 27 May 2015 14:09:47 +, Adam D. Ruppe wrote: Two options: 1) add an overload that takes typeof(null) this(typeof(null)) { /* handles the null literal specially */ } you keep breaking my box of thinking. ;-) never thought about such declaration. signature.asc Description: PGP

Re: Null argument and function resolution

2015-05-27 Thread Meta via Digitalmars-d-learn
On Wednesday, 27 May 2015 at 19:38:16 UTC, ketmar wrote: On Wed, 27 May 2015 14:09:47 +, Adam D. Ruppe wrote: Two options: 1) add an overload that takes typeof(null) this(typeof(null)) { /* handles the null literal specially */ } you keep breaking my box of thinking. ;-) never thought

Re: Null argument and function resolution

2015-05-27 Thread Timon Gehr via Digitalmars-d-learn
On 05/27/2015 10:09 PM, Meta wrote: On Wednesday, 27 May 2015 at 19:38:16 UTC, ketmar wrote: On Wed, 27 May 2015 14:09:47 +, Adam D. Ruppe wrote: Two options: 1) add an overload that takes typeof(null) this(typeof(null)) { /* handles the null literal specially */ } you keep breaking