Implicit conversions for AA keys

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Mar 23 12:30:48 PDT 2012


On Fri, Mar 23, 2012 at 02:06:15PM -0500, Andrei Alexandrescu wrote:
[...]
> A cast would be needed anyway because they have different types,
> too. Anyway upon more thinking maybe this is too restrictive a rule.
> It won't catch e.g. functions that are, in fact, identical, but come
> from distinct instantiations.
> 
> So perhaps you need some conservative approximation, i.e. look if
> the two types are qualified versions of the same type and then
> assume they hash the same.

OK. Would the following be enough?

	template isEquiv(T,U) {
		enum isEquiv = is(immutable(T)==immutable(U));
	}


[...]
> >Isn't this already required by the hash lookup? Or is casting
> >different from to!X, in which case it might be messy to import the
> >relevant parts of phobos into druntime. :-/
> 
> Casting is very different from to, and useless for your purposes.  You
> must use to.
[...]

Wouldn't that require moving std.conv into druntime?  And std.conv does
depend on std.traits as well...


T

-- 
Without outlines, life would be pointless.


More information about the Digitalmars-d mailing list