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
947 stars 135 forks source link

Fix common type of dimensionless and arithmetic types #207

Closed JohelEGP closed 5 years ago

JohelEGP commented 5 years ago

I didn't consider these specializations back then. While further testing my quantity concepts, I tested whether the dimensionless units and arithmetic types behaved like quantities of the same dimension, and it failed. I don't know if it's the cause, but I realized that there weren't std::common_type specializations for dimensionless units and arithmetic types, unlike how there are ordering and arithmetic operators for them. You'll see that, in the test I added in this PR, there are inconsistencies in the common type. Some are dimensionless units, other are arithmetic types.

nholthaus commented 5 years ago

looks like it doesn't work on gcc, but it's not immediately clear why. May be a bug since the most pedantic compiler (clang) and least pedantic (msvc) both build it OK.

JohelEGP commented 5 years ago

I'm not sure. GCC 8 rejects it, too, but Clang 7 (and probably 6) continue to accept it. That said, I'll refactor it to be like before, so that GCC 7 doesn't find it ambiguous, but works as I intended it to be (for strong units). I'll change the approach to solving the main issue.

JohelEGP commented 5 years ago

You'll notice that the added tests are commented out. That's because I was working towards making them valid, and the GCC hiccup was more about a drive-by fix.