You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to cast a quantity to it's numerical representation I can use quantity_cast. That's great. What I think could also be very helpful is a shorthand for casting a quantity to a different unit. Now I know that this can be done like so:
boost::units::quantity<boost::units::si::length, double> siLength;
auto cgsLength = static_cast<boost::units::quantity<boost::units::cgs::length, double>>(siLength);
However this feels kinda more bulky than it'd need to be. It would be very neat if something like this would be possible:
boost::units::quantity<boost::units::si::length, double> siLength;
auto cgsLength = unit_cast<boost::units::cgs::length>(siLength);
So essentially I am asking for a way to cast to a different (compatible) unit without having to explicitly write that I want to cast it to a quantity again. That should be deduced. Thus when starting from a quantity of double, I'd expect this cast to automatically cast to a quantity of double as well. Same for int and all other types.
Would something like this be possible? 🤔
The text was updated successfully, but these errors were encountered:
Krzmbrzl
changed the title
Quantity_cast for unit
[Feature Request]: unit_cast
Nov 29, 2019
When I try to cast a quantity to it's numerical representation I can use
quantity_cast
. That's great. What I think could also be very helpful is a shorthand for casting a quantity to a different unit. Now I know that this can be done like so:However this feels kinda more bulky than it'd need to be. It would be very neat if something like this would be possible:
So essentially I am asking for a way to cast to a different (compatible) unit without having to explicitly write that I want to cast it to a quantity again. That should be deduced. Thus when starting from a quantity of double, I'd expect this cast to automatically cast to a quantity of double as well. Same for int and all other types.
Would something like this be possible? 🤔
The text was updated successfully, but these errors were encountered: