nholthaus / units

a compile-time, header-only, dimensional analysis and unit conversion library built on c++14 with no dependencies.
http://nholthaus.github.io/units/
MIT License
952 stars 135 forks source link

beginner question about inverse #173

Closed RallyTronics closed 6 years ago

RallyTronics commented 6 years ago

I have the following test program and am using VS2017 `

include "units.h"

using namespace units; using namespace units::temperature; using namespace units::energy; using namespace units::substance; using namespace units::pressure; using namespace units::literals;

static constexpr const unit_t<compound_unit<joules, inverse>> enthalpy_of_vaporization_H2O(40660);

int main(void) { kelvin_t x = enthalpy_of_vaporization_H2O / constants::R; unit_t<inverse> ix = constants::R / enthalpy_of_vaporization_H2O; } ` compilation succeeds on the first line but fails on the second, what is the lhs type here?

thanks!

[edited to clarify]

cb-therm commented 6 years ago

Second line should be "kelvin", not "kelvin_t". The "_t" marks it as an actual unit container that has some numeric value, whereas the unit without the "_t" is more of a flag used for dimensional analysis.

RallyTronics commented 6 years ago

Great, thanks!