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

cannot convert coulomb/volt into farad #148

Closed vl-01 closed 2 years ago

vl-01 commented 6 years ago
farad_t one_farad()
{ return coulomb_t(1) / volt_t(1); }

fails to compile with

error: static assertion failed: Units are not compatible.
nholthaus commented 6 years ago

which version are you using?

vl-01 commented 6 years ago

Latest. sha1 of units.h is 40be29223786b357c23f8defea83fb516b5601dc

nholthaus commented 6 years ago

try out v3 alpha 2, which is the preview of the next version. That's where all the dev effort and bug fixes have gone into lately. The capacitance dimensional analysis is working correctly in that version.

vl-01 commented 6 years ago

Unfortunately that version relies on inline variables and void_t, which aren't present in C++14 (I'm using gcc 5.4)

JohelEGP commented 6 years ago

On CE: https://godbolt.org/g/5QYUsZ (C++17, trunk), https://godbolt.org/g/yPEygd (C++14, master). Seems to be working fine.

vl-01 commented 6 years ago

https://godbolt.org/g/K6zRZE shows the error. Inline constexpr variables are in units.h but CE doesn't seem to hit the error on the included file for some reason.

There are also some uses of inline variables from the standard library (has_trait_v) that aren't available in C++14.

JohelEGP commented 6 years ago

The v3.x branch and the v3 alpha releases require C++17.