digitalmars.D.learn - is is cast on hash required
- Dan (27/27) Nov 15 2012 Is there a way around the cast below to see if ci is i?
- bearophile (5/6) Nov 15 2012 I have added a related bug report:
Is there a way around the cast below to see if ci is i?
If not, is there already a standard template method that does
DeepUnqual.
Finally, if not a workaround is this safe?
Thanks
Dan
----------------------
import std.traits;
void main() {
const(int[string]) ci;
int[string] i;
// FAILS TO COMPILE if(ci is i) { }
if(cast(DeepUnqual!(typeof(ci)))ci is
cast(DeepUnqual!(typeof(i)))i) { }
}
template DeepUnqual(T) {
static if(isAssociativeArray!T) {
alias Unqual!(Unqual!(ValueType!T)[Unqual!(KeyType!T)])
DeepUnqual;
} else static if(isDynamicArray!T) {
alias Unqual!(Unqual!(ArrayElementType!T)[]) DeepUnqual;
} else static if(isPointer!T) {
alias Unqual!(PointerTarget!T) * DeepUnqual;
} else {
alias Unqual!T DeepUnqual;
}
}
Nov 15 2012
Dan:Is there a way around the cast below to see if ci is i?I have added a related bug report: http://d.puremagic.com/issues/show_bug.cgi?id=9031 Bye, bearophile
Nov 15 2012








"bearophile" <bearophileHUGS lycos.com>