Closed kwikius closed 3 years ago
The answer to this is that std::chrono got this wrong. Since a UDL can figure out the smallest type that can hold its value UDT's should return the smallest type that can hold the value as shown here
TODO flesh out bespoke user defined literal example and make it the way for all UDLs in the example si system
Fixed
Every model of quantity has an underlying numeric type ( e.g double) and for convenience this is allowed to default to some real_type, which can be theoretically modified in \<pqs/bits/config.hpp>. This is particularly convenient for me when working with contemporary arm microcontrollers which often have hardware floating point support for float or double but not long double, so I can make the default match the optimum for the microcontroller.
However this makes things inconvenient when working with for example std::chrono_duration literals which return a type with a long double numeric value, because conversion to a type with a double is disallowed due to it being a narrowing conversion \<pqs/concepts/associated/basic_quantity.hpp>#L31 https://github.com/kwikius/pqs/blob/master/examples/chrono_duration_support.cpp#L100 Maybe there should not be any default numeric type e.g. for the quantity typedefs \<pqs/systems/si/quantity/quantity_macro.hpp>#L9 , which would be more typing but less confusing