Date: Tue, 18 Jun 2024 18:43:10 +0000
> I admit that I have less working familiarity with mp-units than Au, simply because I use the latter in my day to day work. But could you please give a more explicit example where the result of an mp-units computation conjures up units that weren't mentioned in any of the inputs? I don't know any, but, again --- I'm less familiar.
The actual type is
mp_units::Temperatur<mp_units::is::degree_Celsius, double>
if I’m not mistaken
here’s the template definition:
/**
* @brief A quantity
*
* Property of a phenomenon, body, or substance, where the property has a magnitude that can be
* expressed by means of a number and a reference.
*
* @tparam R a reference of the quantity providing all information about quantity properties
* @tparam Rep a type to be used to represent values of a quantity
*/
template<Reference auto R, RepresentationOf<get_quantity_spec(R).character> Rep = double>
class quantity;
and has only 1 member:
Rep numerical_value_is_an_implementation_detail_;
> This approach is what we might call the "arbitrary functional forms" approach. It's very ambitious for a units library, and there's a lot to like about it. I believe that in principle, there are use cases that this approach could handle that the quantity / quantity-point approach couldn't (although I don't know any off the top of my head).
If you had to handle things like logarithmic units, it would be this exact same solution, it’s a type whose math works differently, not some form of hyper-space concept.
> However, it seems to me that it has a defect: there are also cases that the quantity / quantity-point approach can handle, that this one can't. One example is the example earlier in the thread, which I'll decline to repeat in detail. Let's focus in on the part that I think would be harder for your approach. Suppose there's some climate scientist communicator who's using C++, and wants a reliable way to convert temperature change thresholds from Celsius to Fahrenheit. Suppose also that we take your preferred design approach in the standard units library. What are you going to tell this person to write?
They can use Celsius and Fahrenheit (or even Kelvin or Rankine) for “absolute temperatures”, for “temperature differences” (or math) you have to use Kelvin or Rankine, and this shouldn’t be strange to a climate scientist.
Received on 2024-06-18 18:43:14