Closed mpusz closed 4 months ago
I would say: 'zero_Celsius' is a synonym (or alias) for 'si::ice_point' and not a (derived) kind of a 'si::ice_point'.
(I have to ask: Is Kelvin a Temperature-Distance? zero_Celsius - si::ice_point == 0 K
?)
I didn't mean it to be treated as a derived thing. Inheritance here is just an implementation detail to create a strongly typed name. We do it for other entities as well. For example:
so what I meant was something like this:
inline constexpr struct zero_Celsius : decltype(ice_point) {} zero_Celsius;
but we can also do:
inline constexpr ice_point zero_Celsius;
which will not introduce a new type, and the user will still see isq::ice_point
even when zero_Celsius
is used in the code.
Is Kelvin a Temperature-Distance?
Kelvin is a unit. quantity<si::kelvin>
is a differential/distance/vector type. quantity_point<si::kelvin, absolute_zero>
is a point type with the internal quantity
value being stored relative to the absolute_zero
point.
zero_Celsius - si::ice_point == 0 K
Yes, that is true. Subtracting two points gives a quantity. As those are the same points, the distance between them is zero. The only exception when we can't subtract two points is when they are absolute_point_origins
as those are unaware of the unit.
For posterity, here's my take on this issue (as shared in our recent WG21 meeting):
zero_Celsius
type to represent the origin. We don't want to force users to rely on implicit knowledge, such as the fact that the "zero" of Celsius is the ice point: better to express intent clearly.Done some time ago
Yesterday, I stumbled upon this article: https://randomascii.wordpress.com/2023/10/17/localization-failure-temperature-is-hard/
and prototyped the following solution for it: https://godbolt.org/z/6jo6xqeb8.
Even though the "ice point" is the correct name for the beginning of the Celsius scale, it looks a bit inconsistent and harder to use compared to Fahrenheits:
Should we add
zero_Celsius
as an alias forsi::ice_point
as well to improve the usability? If so, should thezero_Celsius
be its own strong type (derived fromsi::ice_point
) or is it enough to just make it an object ofsi::ice_point
type. The difference will be visible in types presented in compile-time errors.