alias this and constructor

monarch_dodra monarchdodra at gmail.com
Sat Apr 12 06:14:21 PDT 2014


On Saturday, 12 April 2014 at 13:08:48 UTC, Jack Applegame wrote:
> On Saturday, 12 April 2014 at 12:47:02 UTC, MrSmith wrote:
>
>> Maybe, because compiler cannot distinguish between default 
>> constructor which takes int and your one, which also takes int.
>
> I don't think so. Without alias this, but with constructor it 
> compiles.

The issue is that a call that was essentially supposed to do 
nothing, accidentally calls your constructor. Because the call 
"that does nothing" was not expected to do much, it was marked as 
@safe, pure and nothrow.

This conflicts with your constructor, which is none of those.

That's the explanation for the behavior you are seeing, it 
shouldn't be happening. You can work around it by marking your 
constructor as @safe, pure and nothrow.

https://github.com/D-Programming-Language/phobos/pull/1529#discussion_r7175502


More information about the Digitalmars-d-learn mailing list