digitalmars.D.learn - static switch
- "cal" <callumenator gmail.com> Jun 11 2012
- Dmitry Olshansky <dmitry.olsh gmail.com> Jun 12 2012
- "bearophile" <bearophileHUGS lycos.com> Jun 12 2012
- "cal" <callumenator gmail.com> Jun 12 2012
Does a switch statement acting on a template parameter act just
like a chain of static if-else's? That is, does it just generate
the code for the matching case?
enum E { A, B, C }
class Blah(E param) {
void foo() {
switch(param) {
case(E.A) : blah;
case(E.B) : ....
default:
}
}
}
Thanks,
cal
Jun 11 2012
On 12.06.2012 10:13, cal wrote:Does a switch statement acting on a template parameter act just like a chain of static if-else's? That is, does it just generate the code for the matching case? enum E { A, B, C } class Blah(E param) { void foo() { switch(param) { case(E.A) : blah; case(E.B) : .... default: } } }
It doesn't. It's easy to check anyway. -- Dmitry Olshansky
Jun 12 2012
cal:Does a switch statement acting on a template parameter act just like a chain of static if-else's? That is, does it just generate the code for the matching case?
See: http://d.puremagic.com/issues/show_bug.cgi?id=6921 Bye, bearophile
Jun 12 2012
On Tuesday, 12 June 2012 at 08:35:44 UTC, Dmitry Olshansky wrote:It doesn't. It's easy to check anyway.
Not for me :) I just saw that it worked, and wondered if it worked statically. Thanks!
Jun 12 2012









Dmitry Olshansky <dmitry.olsh gmail.com> 