From: Steven Watanabe (steven_at_[hidden])
Date: 2007-03-28 11:58:09
Michael Fawcett <michael.fawcett <at> gmail.com> writes:
> > No more switch statement smell.
> I agree on the smell...Thankfully it's very contained when using the
> compile-time version. It seems like with a run-time component that
> was interoperable with the compile-time one, you could have zero
> run-time overhead during computations as well as get rid of all switch
> statements at the boundaries (reading/writing from database or GUI).
> Something like:
> quantity<SI::length> on_dialog_ok()
> quantity<abstract> dist;
> return quantity<SI::length>(dist);
Here is how I would do it:
double conversion = combo.selected_item().data();
double value = entry.value().as_double();
return quantity<SI::length>::from_value(conversion * value);
Absolutely minimum overhead.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk