July 12, 2004 Associative array with struct as keytype now links, but still doesn't work | ||||
---|---|---|---|---|
| ||||
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.
|
July 12, 2004 Re: Associative array with struct as keytype now links, but still doesn't work | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | The typeinfo's are not right for structs, yet, I'll let you know when they are! |
Copyright © 1999-2021 by the D Language Foundation