array of elements of various sybtypes

Jesse Phillips jessekphillips+D at gmail.com
Wed Jan 26 16:17:39 PST 2011


> 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 :)


More information about the Digitalmars-d-learn mailing list