Commit Graph
232 Commits
Author SHA1 Message Date
Mateusz Pusz d50ed286b3 Merge pull request #381 from JohelEGP/llvm16
refactor: update hacks for LLVM 16
2022-07-30 10:49:44 +02:00
Johel Ernesto Guerrero Peña e988e1d74e refactor: update hacks for LLVM 16 2022-07-29 17:17:07 -04:00
Chip Hogg f6f7f9bafb Explicitly qualify mag<> that initializes mag member
This should fix clang's complaint.
2022-07-29 14:18:33 +00:00
Chip Hogg ea83af8aa9 Rename as_magnitude<...>() to mag<...>()
This is easier to write and to read.
2022-07-29 01:46:06 +00:00
Chip Hogg 0adee83866 Use mag_power to make callsites more concise 2022-07-27 14:30:38 +00:00
Chip Hogg 7e591115fa Remove ratio's numerator() and denominator()
These have now become trivial.
2022-07-20 00:52:37 +00:00
Chip Hogg 7fd6913b73 Replace exp with 0 everywhere, and remove it
This lets us remove a ton of special-casing throughout the codebase, and
just generally makes things a lot simpler.

We also remove the ability to take rational powers of `ratio`, including
`sqrt` and `cbrt` helpers, because these are intrinsically ill-defined.

Fixes #369.
2022-07-20 00:52:37 +00:00
Chip Hogg e1a173a02d Migrate prefixes to Magnitude 2022-07-07 17:09:42 +00:00
Chip Hogg 92750072b0 Reimplement ratio_text() as magnitude_text()
The algorithm is exactly the same; we just get our values for
`num_value`, `den_value`, and `exp10` in different ways.

The old printing logic assumed the ratio/Magnitude was an exact rational
number.  Formerly, we couldn't even _represent_ anything else, but with
Magnitude, we can.  Thus, we guard this assumption with a
`static_assert`.  Later on, we can figure out how we want to print
irrational bases and/or rational powers.  The point of this change is to
unblock us from moving to the new infrastructure.
2022-07-07 16:44:19 +00:00
Chip Hogg e1a17ab1f0 Use variables instead of ratio members
This prepares us for a time when we won't _have_ the `ratio` members
(because we'll be using `Magnitude`).
2022-07-07 16:33:51 +00:00
Chip Hogg 407a13c48f Add extract_power_of_10(Magnitude) utility
This will help with pretty-printing magnitudes by extracting a
reasonable power of 10.
2022-07-07 16:10:34 +00:00
Chip Hogg f004854a9e Remove useful names to appease MSVC 14
Looks like another compiler bug, where it considers a formal parameter
to be "unused" if it isn't used in any `if constexpr` branch.
2022-06-15 21:44:27 +00:00
Chip Hogg ef9e6522ca Merge branch 'master' into chiphogg/switch-to-mag 2022-06-15 20:50:30 +00:00
Mateusz Pusz f5e6d052ad fix: MSVC compilation error workaround 2022-06-09 13:50:41 +02:00
Mateusz Pusz 46b3781743 Revert "refactor: 💥 ! " ⋅ " replaced with "⋅" in derived unit symbols"
This reverts commit db09a065ab.
2022-05-24 14:20:17 +02:00
Mateusz Pusz 38fb9911a9 refactor: 💥 ! " ⋅ " replaced with "⋅" in derived unit symbols 2022-05-24 12:56:14 +02:00
Mateusz Pusz db09a065ab refactor: 💥 ! " ⋅ " replaced with "⋅" in derived unit symbols 2022-05-24 12:48:07 +02:00
Mateusz Pusz ef7e7c4cfc refactor: detail::same_scaled_units renamed to detail::compatible_units 2022-05-23 20:47:29 +02:00
Mateusz Pusz 842f2eaf27 feat: quantity CTAD guide added 2022-05-22 19:47:11 +02:00
Mateusz Pusz 43844c484c fix: UNITS_MSVC_WORKAROUND() fixed for other compilers 2022-05-14 11:27:12 +02:00
Mateusz Pusz b559a5f98f fix: explicit ratio creation added as a workaround for MSVC 2022-05-14 11:24:00 +02:00
Mateusz Pusz 6c1062e166 fix: UNITS_MSVC_WORKAROUND() added 2022-05-14 11:22:09 +02:00
Chip Hogg 86b81c9384 Undo misguided fix attempt 2022-05-12 21:53:51 +00:00
Chip Hogg 2bdc778ab6 Constrain template 2022-05-12 18:19:20 +00:00
Chip Hogg f36205f08d Capture NTTP in variable
This should make it OK for MSVC to take the address, working around a
compiler bug.
2022-05-12 18:17:35 +00:00
Chip Hogg 88a69cecd8 Try fixing build
Unfortunately, my local build hangs, so I can't tell whether this works.
2022-05-12 18:02:47 +00:00
Chip Hogg a0ac140a19 Merge fixes into branch after updating with upstream changes 2022-05-12 16:54:48 +00:00
Chip Hogg 59fa420272 Fix remaining builds/tests 2022-05-12 16:52:05 +00:00
Chip Hogg 5fb468697b Merge branch 'master' into chiphogg/switch-to-mag 2022-05-12 16:12:01 +00:00
Mateusz Pusz 0765fb26a2 fix: MSVC complains that an address of NTTP is taken here 2022-05-12 10:55:48 +02:00
Mateusz Pusz 0ed43d3087 fix: restoring original as_magnitude implementation as it was correct 2022-05-11 23:58:30 +02:00
Mateusz Pusz 54489a57b2 refactor: missing constraints on a return type added
Implementation verification and interface documentation purposes
2022-05-11 22:56:58 +02:00
Mateusz Pusz b3afd61b2d refactor: duplicated concepts checks removed to improve compile times
`magnitude` template parameters are already checked during `magnitude` type instantiation.
2022-05-11 22:55:55 +02:00
Mateusz Pusz 104923d1aa refactor: as_ratio() constrain simplified 2022-05-11 22:52:40 +02:00
Mateusz Pusz bd5a476bab fix: pow<> requires a ratio as a template argument
Thank you @Nostracodus and @TartanLlama!
2022-05-11 22:52:03 +02:00
Mateusz Pusz 7737167d1d fix: unit symbol text output unit tests fixed 2022-05-11 18:10:51 +02:00
Mateusz Pusz 5300caf17b refactor: 💥 ! derived_deduced_unit renamed to derived_scaled_unit
Naming is hard ;-)
2022-05-11 12:34:52 +02:00
Mateusz Pusz 32b36fb670 refactor: 💥 ! PrefixFamily support removed
It doesn't have much sense to restrict prefixes usage for most units and in many places we were wrong to do so already.
2022-05-11 11:59:33 +02:00
Mateusz Pusz 725d193122 refactor: 💥 ! U::is_named removed from the unit types and replaced with NamedUnit concept 2022-05-11 11:49:14 +02:00
Mateusz Pusz 0522bae972 refactor: 💥 ! unit renamed to derived_unit 2022-05-11 11:40:19 +02:00
Mateusz Pusz f5d21a0711 refactor: 💥 ! derived_unit renamed to derived_deduced_unit 2022-05-11 11:23:18 +02:00
Mateusz Pusz 8d0b643bb3 refactor: 💥 !named_derived_unit removed as it was not used 2022-05-11 11:10:15 +02:00
Mateusz Pusz 4c60447a28 Merge branch 'master' into downcast_mode_off 2022-05-09 19:12:02 +02:00
Mateusz Pusz 0033319451 fix: shadowing compilation errors on MSVC fixed 2022-05-05 16:12:54 +02:00
Chip Hogg 2b37bc7b3e Address review feedback 2022-04-19 15:42:43 +00:00
Chip Hogg 94fe48dd64 Add <compare> to satisfy clang 2022-04-12 00:44:53 +00:00
Chip Hogg c805a9390f Implement suggestion 2022-04-12 00:40:42 +00:00
Chip Hogg 78bcb3b019 Remove troublesome ::ratio members
For some reason, MSVC seems to want to instantiate these, even though
nobody ever asks for them (as evidenced by the fact that the builds
passed on other architectures).
2022-04-12 00:35:17 +00:00
Chip Hogg d19b2803ce Migrate units from ratio to Magnitude
This commit is huge, but hopefully the cognitive load is not too bad.
The bulk of this commit is just some fairly mechanical updates from
`ratio` to `Magnitude`.  Other things to call out:

- `UnitRatio` goes away.  We don't need this concept, because Magnitude
  can't even _represent_ anything that doesn't satisfy it.

- I commented out some formatting test cases where the precise
  expression changes, but the number is completely equivalent.  We will
  need to decide how we want to handle Magnitude formatting as a
  separate, follow-on task.  But at least Magnitude gives us all the
  tools we'll need to do so!
2022-04-11 15:16:16 +00:00
Chip Hogg 5afe7766e9 Use Magnitude implementation for base_units_ratio
This resolves a TODO and lets us use arbitrary exponent denominators.

I also attempt to clarify the semantics.  This is based on my best
effort of understanding pre-existing concepts in the library, so I hope
I got it right!
2022-04-11 15:16:16 +00:00