Template specification conflict

simendsjo simendsjo at gmail.com
Tue Aug 2 05:06:33 PDT 2011


On 02.08.2011 13:55, Dmitry Olshansky wrote:
> On 02.08.2011 15:06, simendsjo wrote:
>> The following program gives me
>> "Error: template t.S.__ctor(C) if(isSomeChar!(C)) conflicts with
>> constructor t.S.this at t.d(4)"
>>
>> Is this because char etc can be converted to uint? Shouldn't the
>> template specification make this unambiguous?
>>
>> import std.traits;
>>
>> struct S {
>> this(uint i) {}
>> this(C)(C c) if(isSomeChar!C) {}
>> }
>>
>> void main() {}
>
> struct S {
> this()(uint i) {}
> this(C)(C c) if(isSomeChar!C) {}
> }
>
> should do it, though it (and workaround) looks like a bug to me.
>

With the empty templated this, I get other errors though:
"t.d(5): Error: constructor t.S.this conflicts with template 
t.S.__ctor() at t.d(4)"

struct S {
     this()(int a) {} // 4
     this(int a, int b) {} // 5
}



More information about the Digitalmars-d-learn mailing list