5 Commits

Author SHA1 Message Date
Mateusz Pusz 7a03123a01 refactor(utility): move safe_int and constrained into the mp_units::utility namespace
safe_int, constrained, their error policies, and the safe_iN aliases are
non-framework add-ons, so their public names move out of mp_units into the
mp_units::utility extension tier (next to the representation concepts already
there). The headers move to core/include/mp-units/utility/ accordingly but stay
in the core component: safe_int reuses the core 128-bit integer toolkit
(integral, is_signed_v, int128_t, ...) that also backs the scaling engine, so it
bridges to mp_units::detail with a single using-directive rather than relocating
or duplicating that toolkit. overflow_policies stays framework (it backs bounded
quantity point origins). No deprecation shims: these types are unreleased.

Also fixes utility/representation.h, whose public concepts delegated via the
unqualified detail::X. That resolved to mp_units::detail only as long as
mp_units::utility::detail did not exist; now that constrained/safe_int introduce
it, the references are qualified to ::mp_units::detail:: so they stay
order-independent (this surfaced only in the module build).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-27 23:58:39 +02:00
Mateusz Pusz 8f4a13f50f fix: silence MSVC Debug C4702 by giving if constexpr chains an explicit else
MSVC's Debug code generator does not dead-code-eliminate after an `if constexpr`
chain whose branches all return, so the fallthrough `return` after the chain is
flagged C4702 (unreachable) on instantiations where one of the branches is
selected.  Release builds optimize the dead path out and never complain.

Restructure two places so the fallback lives inside an explicit `else` /
returning helper instead of a fallthrough:

  * `enforce_bounds()` (quantity_point.h): wrap the `return q;` fallback in
    `else { return q; }` after the existing `if constexpr` chain.
  * `compare_quantities()` (quantity.h): hoist the floating-point / already-widest
    fallback into a local `fallback_cmp` lambda invoked from both arms of the
    `if constexpr` chain.  Keeps the existing float-equal suppression.

For `CHECK_THROWS_AS` in constrained_test.cpp, Catch2's macro expands into a
try/catch whose catch arm becomes unreachable when the body calls a `[[noreturn]]`
function; suppress C4702 around that one TEST_CASE since the macro is not ours
to restructure.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 21:52:39 +02:00
Mateusz Pusz 0a33e0a0e6 refactor: quantity point bounds are now specified directly in origin - quantity_bounds_for customization point removed 2026-04-25 21:00:31 +02:00
Mateusz Pusz 76a7692180 test: constrained runtime unit tests refactored to SECTIONS 2026-04-11 20:32:39 +02:00
Mateusz Pusz 459211fc7a feat: quantity point bounds design finalized 2026-04-03 23:38:47 +02:00