I have been playing with Boost.Units as part of a work project recently, and I am not sure what the best approach to "demarshalling" values in a specific unit. For example, I would like to do something like:
using namespace boost::units;
struct A {
enum { feet, kilometers };
quantity<si::length> some_length;
double foo(int type) {
switch(type) {
case feet:
return quantity<feet>(some_length).value();
case kilometers:
return quantity<kilometers>(some_length).value();
}
}
};
This approach is necessary for passing values to external libraries which do not (and probably will never) use Boost.Units. Is conversion_factor the best approach, or is there a way to achieve this implicitly using the type system?
Thanks
Justin