To use opDispatch
BCS
none at anon.com
Sun May 23 12:06:29 PDT 2010
Hello bearophile,
> I have seen this bug report:
> http://d.puremagic.com/issues/show_bug.cgi?id=4224
> Do you know any way to make the following code work? It can be useful,
> especially once the int type can be replaced with a good variant type:
>
> struct A {
> int[string] table;
> int opDispatch(string s)() {
> return table[s];
> }
> void opDispatch(string s)(int x) {
> table[s] = x;
> }
> }
> void main() {
> A a;
> a.i = 10;
> assert(a.i == 10);
> }
IIRC I got more or less what you want somewhere in here:
http://dsource.org/projects/scrapple/browser/trunk/units/si2.d
I'll see if I can chop it down a bit.
--
... <IXOYE><
More information about the Digitalmars-d
mailing list