Partial ordering of constructors with type parameters

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Apr 23 09:55:33 PDT 2014


Charles McAnany:

>     this(int x){}
>     this(T)(T x) if(!is(T == int)){}
> }
> void main(){}
>
> But this does not compile because the two constructors conflict:

Try adding the negative constraint:

this(T)(in T x) pure nothrow if(is(T == int)) {}
this(T)(in T x) pure nothrow if(!is(T == int)) {}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list