switch case for constants-only?
Nick Sabalausky
a at a.a
Sat Dec 5 16:30:29 PST 2009
"BCS" <none at anon.com> wrote in message
news:a6268ffdcb78cc43db75126b3c at news.digitalmars.com...
>
> Just jumping a ways down this rabbit hole...
>
> struct S { int i; int opCmp(S s) { return i-- == s.i++; }
>
> {
> S a,b,c,d,e; ...
> switch(a)
> {
> case b: break;
> case c: break;
> case d: break;
> case e: break;
> }
> }
>
> Oh, boy. What the hack does the above do?
>
It blatantly abuses operator overloading ;) Start doing stuff like that,
and you'll wind up in wonderland even without changing switch.
More information about the Digitalmars-d
mailing list