November 15, 2012 is is cast on hash required | ||||
|---|---|---|---|---|
| ||||
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;
}
}
| ||||
November 15, 2012 Re: is is cast on hash required | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Dan | 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 | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply