Error using `equal` with various string types

Jonathan M Davis jmdavisProg at gmx.com
Sun Feb 24 03:35:03 PST 2013


On Sunday, February 24, 2013 12:24:21 monarch_dodra wrote:
> On Sunday, 24 February 2013 at 04:47:41 UTC, Jonathan M Davis
> 
> wrote:
> > However, now that I think about it, equal takes a predicate, so
> > it would
> > probably work to do something like
> > 
> > equal!"equal(a, b)"(["hello"d], ["hello"]);
> > 
> > - Jonathan M Davis
> 
> Yes, and you don't even need to use a mixin.
> 
> This is a known "issue", and is specifically covered and
> "pseudo-documented" the source unittests.
> 
> Copy pasted straight from the source:
> 
> //Should not compile, because "string == dstring" is illegal
> static assert(!is(typeof(equal(["hello", "world"], ["hello"d,
> "world"d]))));
> //However, arrays of non-matching string can be compared using
> equal!equal. Neat-o!
> equal!equal(["hello", "world"], ["hello"d, "world"d]);

Given that equal is a templated function, I'm surprised that it's possible to 
pass it without it being fully instantiated. Usually, templates have to be 
fully instantiated before you can alias them.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list