digitalmars.D.bugs - Associative array with struct as keytype now links, but still doesn't
- Stewart Gordon <smjg_1998 yahoo.com> Jul 12 2004
- "Walter" <newshound digitalmars.com> Jul 12 2004
Using DMD 0.95, Windows 98SE.
The program below used to give linker errors about missing TypeInfo
stuff, but now it links fine.
However, lookups in it never match. Output:
No such element
No such element
No such element
Guess this is one for the TypeInfo-per-type fix...?
Stewart.
----------
import std.c.stdio;
import std.ctype;
struct IChar {
char data;
int opEquals(IChar i) {
return toupper(data) == toupper(i.data);
}
uint toHash() {
return toupper(data);
}
int opCmp(IChar i) {
return toupper(data) - toupper(i.data);
}
}
int main() {
int[IChar] aa;
static IChar c1 = { 'c' };
static IChar c2 = { 'c' };
static IChar c3 = { 'C' };
aa[c1] = 4;
if (c1 in aa) { // fails 0.95 - should display 4
printf("%d\n", aa[c1]);
} else {
puts("No such element");
}
if (c2 in aa) { // fails 0.95 - should display 4
printf("%d\n", aa[c2]);
} else {
puts("No such element");
}
if (c3 in aa) { // fails 0.95 - should display 4
printf("%d\n", aa[c3]);
} else {
puts("No such element");
}
return 0;
}
--
My e-mail is valid but not my primary mailbox, aside from its being the
unfortunate victim of intensive mail-bombing at the moment. Please keep
replies on the 'group where everyone may benefit.
Jul 12 2004
The typeinfo's are not right for structs, yet, I'll let you know when they are!
Jul 12 2004








"Walter" <newshound digitalmars.com>