www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Error using `equal` with various string types

reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
It seems this doesn't work:

import std.algorithm;
auto b1 = qual(["foo"d], ["foo"]);
auto b2 = equal(["foo"d.dup], ["foo"]);

It's due to a constraint failure:
is(typeof(r1.front == r2.front))

The first call is:
immutable(dchar)[]
string

The second:
dchar[]
string

Anyway can we make `equal` work with these? It would be really useful
if it worked.
Feb 23 2013
parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Sat, 23 Feb 2013 22:39:55 -0500, Andrej Mitrovic  
<andrej.mitrovich gmail.com> wrote:

 It seems this doesn't work:

 import std.algorithm;
 auto b1 = qual(["foo"d], ["foo"]);
 auto b2 = equal(["foo"d.dup], ["foo"]);

 It's due to a constraint failure:
 is(typeof(r1.front == r2.front))

 The first call is:
 immutable(dchar)[]
 string

 The second:
 dchar[]
 string

 Anyway can we make `equal` work with these? It would be really useful
 if it worked.
Need an overload with a constraint like: if(isInputRange!typeof(r1.front) && isInputRange!typeof(r2.front) && is(typeof(equal(r1.front, r2.front)))) that recursively calls equal -Steve
Feb 23 2013