TDPL: Overloading template functions
Philippe Sigaud
philippe.sigaud at gmail.com
Sun Aug 1 23:08:53 PDT 2010
On Mon, Aug 2, 2010 at 00:37, Andrej Mitrovic <andrej.mitrovich at gmail.com>wrote:
>
> That's because the first part of the constraint is tested, to allow for
>> short-circuiting the second part. So the bad array comparison triggers the
>> problem in object._EqArray.
>>
>> You should always test for the most general constraint first, I guess. In
>> this particular case, use areComparable!(A,B) as the first argument to && in
>> both templates.
>>
>>
> Let me see if I'm getting this right.
>
> false && true will short circuit to false (this is normal).
>
> true && false will short circuit to true? How can that be? It's not a
> logical OR, its an AND, and as far as I know both expressions need to be
> True to evaluate to True. Or is it different for template constraints?
>
I was answering you about the "incompatible types" error. The first part of
the template, 'is(typeof(longer[0 .. 1] == shorter) : bool', triggers the
error and that stops the compilation process. I agree that, if longer[0..1]
== shorter is an error, then we could have is(typeof()) result in 'true'.
But here what happens is that everything stops. I'll post about this on the
main list, see if it's normal behavior or not and add a bug report.
Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100802/b4ec37f1/attachment.html>
More information about the Digitalmars-d
mailing list