Can I retrieve base units from divide_typeof_helper?

62 Views Asked by At

We did define the relevant units (base and derived) that we plan to use in our application. Some derived units have been defined using divide_typeof_helper (e.g km_per_hour_unit for speed quantities).

using namespace boost::units;

namespace my_units
{
    typedef metric::hour_base_unit::unit_type   hour_unit;
    typedef kilometer_base_unit::unit_type   kilometer_unit;
    typedef divide_typeof_helper<kilometer_unit, hour_unit>::type km_per_hour_unit;
}

Now... supposing that I know I am dealing with km_per_hour_unit, is there a way that I can retrieve the units that were used as numerator and denominator for the speed derived unit?

I would love to somehow reach kilometer_unit and hour_unit from km_per_hour_unit.

Any hints?

1

There are 1 best solutions below

2
Lightness Races in Orbit On

According to the documentation, there would be no way to reclaim that information.

This being said, the synopsis there is invalid C++ anyway (how is a typedef a member function? and what's the alias's name?) so perhaps take that with a pinch of salt and double-check on a Boost mailing list.