array of elements of various sybtypes

spir denis.spir at gmail.com
Wed Jan 26 17:27:05 PST 2011


On 01/27/2011 01:17 AM, Jesse Phillips wrote:
>> Right, casting a /single/ element works:
>>       auto x = [cast(T0)(t1), t2];
>>       auto y = [t1, cast(T0)(t2)];
>
> So I guess it was implemented as "Common type within the given set."
>
>> But to! fails:
>>       auto x = [to!(T0)(t1), t2];
>>       auto y = [t1, to!(T0)(t2)];
>> /usr/include/d/dmd/phobos/std/conv.d(99): Error: template std.conv.toImpl(T,S)
>> if (!implicitlyConverts!(S,T)&&  isSomeString!(T)&&  isInputRange!(Unqual!(S))
>> &&  isSomeChar!(ElementType!(S))) toImpl(T,S) if (!implicitlyConverts!(S,T)&&
>> isSomeString!(T)&&  isInputRange!(Unqual!(S))&&  isSomeChar!(ElementType!(S)))
>> matches more than one template declaration,
>> /usr/include/d/dmd/phobos/std/conv.d(559):toImpl(Target,Source) if
>> (implicitlyConverts!(Source,Target)) and
>> /usr/include/d/dmd/phobos/std/conv.d(626):toImpl(T,S) if (is(S : Object)&&
>> is(T : Object))
>>
>> Already had this endless error message once ;-)
>> Looks like another bug of non mutually exclusive template constraints?
>
> Yep, looks like. See I told you 'to' was safe, can't be more safe than not allowed :)

Yep, greatest safety ever ;-) I'll file a bug (as soon as I have time to search 
whether it does already exist on the issue tracker).

Denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d-learn mailing list