Commit Graph

49 Commits

Author SHA1 Message Date
Mateusz Pusz 982fc526c0 feat: 💥 quantity_from_unit_zero() renamed back to quanity_from_zero() and limited to default_point_origin + qp.in(Unit) changes the origin for offset units 2026-05-21 22:46:12 +02:00
Mateusz Pusz 8d8e9f73ff fix: operator-(qp1, qp2) constraints fixed to work with altitude and height in V2 2026-05-13 18:08:30 +02:00
Mateusz Pusz 6858fdbd3b feat: quantity_point::zero() static member function added for points with natural_point_origin 2026-05-06 22:23:03 +02:00
Mateusz Pusz 2978c1963f fix: missing constraints for qp.quantity_from_unit_zero() added + fixed all incorrect usa cases 2026-05-06 22:12:50 +02:00
Mateusz Pusz a89b93bab2 feat: 💥 Celsius_temperature removed from ISQ 2026-04-04 09:11:33 +02:00
Mateusz Pusz 2c7f55e1d5 style: pre-commit 2026-03-31 22:09:48 +02:00
Mateusz Pusz c30a637ae7 refactor: 💥 zeroth-names deprecated; quantity_from_unit_zero(); natural_point_origin 2026-03-31 22:03:03 +02:00
Mateusz Pusz 10b4fcdcab fix: improve efficiency and accuracy of value_cast for quantity_point (#765)
Rewrite the quantity_point overload of sudo_cast to pick the best
intermediate unit/rep for each conversion case:

- Same origin: delegate entirely to the quantity sudo_cast (unchanged).
  Also fix a pre-existing bug where the result was incorrectly tagged
  with FromQP::point_origin instead of ToQP::point_origin.
- Same unit, different origin: skip unit scaling altogether; compute the
  origin offset in the common rep and add it directly.
- Different unit, floating-point rep: pick the larger of the two units
  as the intermediate (to minimise the scaling magnitude), then use
  point_for() to let the library's common-unit arithmetic handle the
  origin shift — this avoids the binary FP precision loss that occurs
  when the offset is expressed explicitly in the larger unit.
- Different unit, integer rep: prefer the output unit as intermediate so
  no extra scaling is needed after the offset addition. If the origin
  offset would overflow the output-unit type, fall back to the input
  unit where it is guaranteed to fit.

Also expand the value_cast tests for quantity_point to cover every
branch explicitly, including the new integer overflow-fallback path.


Closes: https://github.com/mpusz/mp-units/pull/598

Co-authored-by: Yves Delley <burnpanck@users.noreply.github.com>
2026-03-07 22:53:36 +01:00
Mateusz Pusz d74f4acc57 feat: unit_for, reference_for, and rep_for added 2026-01-28 19:28:31 +01:00
Mateusz Pusz 9a374a5646 refactor: isq::time swapped with isq::duration 2026-01-09 09:22:37 +01:00
Mateusz Pusz fdfaefc89f fix: quantity_cast support fixed for quantity_point 2025-12-29 18:40:34 +01:00
Mateusz Pusz 06d157565d feat: explicit quantity_spec conversions added for quantity_point 2025-12-29 18:39:09 +01:00
Mateusz Pusz 9c140f4b3a feat: explicit constructor now can perform an explicit quantity_spec conversion 2025-06-20 17:10:34 +02:00
Mateusz Pusz f18aa18869 refactor: compund assignment and pre-/post-increment operators are now lvalue-qualified member functions 2025-06-19 18:49:21 +02:00
Mateusz Pusz 06cbfae3b3 feat: quantity_spec conversions improved 2024-12-28 14:02:03 +01:00
Mateusz Pusz b77aa52355 refactor: absolute renamed to point
Resolves #645
2024-11-24 14:19:16 +01:00
Mateusz Pusz 2590aa4b80 refactor: MP_UNITS_NONCONST_TYPE introduced to benefit from the C++23 feature 2024-11-13 21:13:22 +01:00
Mateusz Pusz 5810420277 refactor: 💥 tag types should not expose their members 2024-11-04 09:40:25 +01:00
Mateusz Pusz dcab80525d refactor: 💥 common_XXX() functions renamed to get_common_XXX()
This is needed to release a name for `common_unit` type that is coming soon.
2024-09-24 09:36:59 +02:00
Mateusz Pusz 0670fbdd9f feat: value_cast<Representation, Unit>() complementary conversion function added 2024-09-13 21:38:59 +02:00
Mateusz Pusz 45013f6752 fix: inline restored for non-template constexpr global variables 2024-09-05 10:06:43 +02:00
Mateusz Pusz 2e840cfdb4 refactor: Repetitive inline constexpr removed as no longer needed
Not needed anymore as stated in cplusplus/draft#4601
2024-09-05 08:43:36 +02:00
Mateusz Pusz b870b85c25 feat: import std; support added
Resolves #595
2024-07-16 17:36:00 +02:00
Mateusz Pusz 2cff579650 feat: representation type template parameter added to value convertion functions
Resolves #588
2024-07-04 22:05:40 +01:00
Mateusz Pusz ba8681f90b feat: 💥 delta and absolute construction helpers 2024-06-30 12:03:24 +02:00
Mateusz Pusz 90d8fda327 feat: qp1.quantity_from(qp2) added 2024-06-25 14:07:08 -05:00
Mateusz Pusz 4b46be7604 refactor: reference specifiers are now variable templates 2024-06-20 09:20:33 +02:00
Mateusz Pusz b38b23ece2 refactor: relative() renamed to delta() 2024-06-20 07:31:22 +02:00
Mateusz Pusz dfac87c631 feat: multiply syntax support to create quantity_point 2024-06-19 21:11:16 +02:00
Mateusz Pusz d03482fa1b feat: absolute and relative reference modifiers support added 2024-06-19 21:10:16 +02:00
Mateusz Pusz b113f6ad0e Merge branch 'master' into feature/more-value-casts 2024-06-14 21:44:19 +09:00
Mateusz Pusz 05fc1e29c8 refactor: 💥 from now on point origins must be marked final + absolute_point_origin does not use CRTP anymore 2024-06-13 19:24:40 +02:00
Mateusz Pusz c69bd140b2 refactor: all units made final 2024-06-06 13:18:45 +02:00
Yves Delley 4b809ec96c Merge branch 'master' into feature/more-value-casts 2024-06-02 08:03:30 +02:00
Mateusz Pusz cd36e6f974 feat: freestanding support added
Resolves #564, #565, and #556
2024-05-30 19:50:02 +02:00
Yves Delley ae912c0efb added one more test; highlighting an issue with detail::common_magnitude_type_impl when both types are the same 2024-05-12 11:47:03 +02:00
Yves Delley f30fac17f0 added a bit of documentation 2024-05-12 11:13:00 +02:00
Yves Delley c0efdb1790 better handle simultaneous change of representation, unit and point_origin in value_cast, to prevent overflow in more cases. 2024-05-12 10:57:33 +02:00
Yves Delley c51baae074 value_cast overloads for ToQ and ToQP 2024-05-10 23:40:54 +02:00
Yves Delley 14f658120e fix value_cast with lvalue references to quantity_point 2024-05-10 23:14:17 +02:00
Yves Delley 8f8b908b3d added more tests, hopefully, the issue does now surface 2024-05-10 23:07:55 +02:00
Yves Delley be8fc9eb98 add tests for value_cast of quantity_point 2024-05-10 22:45:33 +02:00
Mateusz Pusz 75f719add7 refactor: code refactored to comply with clang-tidy 2024-05-08 11:12:38 +02:00
Mateusz Pusz 8ea346be1c refactor: 💥 header files with the entire system definitions moved up in the directory tree 2024-04-25 16:34:11 +02:00
Mateusz Pusz c066104af7 refactor: 💥 framework.h introduced + IWYU 2024-04-24 21:09:29 +02:00
Mateusz Pusz 15389107d4 fix: dependencies on cstdint header fixed 2024-04-23 08:59:14 +02:00
Mateusz Pusz f1639a038b style: headers reordered to make pre-commit happy 2024-02-23 22:24:26 +01:00
Mateusz Pusz 5ca9168381 feat: proper exports implemented for C++ modules 2024-02-23 21:09:17 +01:00
Mateusz Pusz 0eaf6e2e56 refactor: modules support redesigned 2024-01-06 08:51:01 +01:00