简体   繁体   中英

Can I retrieve base units from divide_typeof_helper?

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 (eg 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM