Null argument and function resolution

Meta via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 27 13:09:19 PDT 2015


On Wednesday, 27 May 2015 at 19:38:16 UTC, ketmar wrote:
> On Wed, 27 May 2015 14:09:47 +0000, 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.

Unfortunately, there is no equivalent way to disable assignment 
of [] at compile time.

struct ArrayWrapper(T)
{
	T[] a;
	
	this(T[] arr) { a = arr; }
	
         //Doesn't work; Conflicts with this(T[] arr)
         //@disable this(typeof(this)[]);

         //Doesn't work; hijacked by this(T[] arr)
         //@disable this(typeof([]));
}


More information about the Digitalmars-d-learn mailing list