Generic degree-rendering formatters, millifahrenheit fix, drop *_real types (2.0.0)#5
Merged
Merged
Conversation
…rop *_real types
Replace the 18 hand-written std::formatter specializations and 15
to_string overloads with two generic templates each. An empty format
spec keeps the exact-count form ("22500m°C"); any floating-point spec
renders the value in scale degrees, so display no longer needs a lossy
cast: std::format("{:.1f}", millicelsius(22534)) == "22.5°C".
BREAKING: millifahrenheit and delta_millifahrenheit used
std::ratio<5, 900> (0.01°F per count) instead of the documented
std::ratio<5, 9000> (0.001°F); counts change meaning by 10x.
BREAKING: the celsius_real/kelvin_real/fahrenheit_real typedefs are
removed - spec-based rendering covers their display use case directly.
Generic floating-point rep support in the templates remains.
This was referenced Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Generic formatters: the 18 hand-written
std::formatterspecializations and 15to_stringoverloads are replaced by two generic templates each. An empty format spec keeps the exact-count form (millicelsius(22500)→"22500m°C"); any floating-point spec renders the value in scale degrees, so readable display no longer needs a lossy cast:Width/alignment pass through to the numeric part; specs on integer types were compile errors before, so this path is purely additive.
millifahrenheitanddelta_millifahrenheitusedstd::ratio<5, 900>(0.01 °F per count) instead of the documentedstd::ratio<5, 9000>(0.001 °F). Counts change meaning by 10×:temperature_cast<millifahrenheit>(fahrenheit(1)).count()was 100, is now 1000. The new conversion tests were written first and confirmed to fail against the old ratio.*_realtypedefs removed:celsius_real,kelvin_real,fahrenheit_realexisted mainly as a display workaround; spec-based rendering covers that directly. Generic floating-point rep support in the templates remains (e.g.temperature<celsius_scale, delta<double>>). Migration: replacestd::format("{:.1f}", temperature_cast<celsius_real>(x))withstd::format("{:.1f}", x).Version bumped to 2.0.0 per semver (removed public API + count reinterpretation).
Test plan
-DCONFIG_THERMO_STD_FORMAT=0 -fsyntax-only