Opened 6 years ago

## #7138 new Bugs

# Output of a UDT with autoprefix requires specialization of auto_prefix_norm

Reported by: | Paul A. Bristow | Owned by: | Steven Watanabe |
---|---|---|---|

Milestone: | Boost 1.51.0 | Component: | units |

Version: | Boost 1.51.0 | Severity: | Problem |

Keywords: | units autoprefix UDT | Cc: |

### Description

Output of a UDT with autoprefix requires specialization of auto_prefix_norm for the scaling to take place. For example, to get expected scaling to kilometers from

quantity<length, measurement<double> > biglen(measurement<double>(12345.0,123.0)*meters); autoscaled = 12.345(+/-0.123) km

This can be achieved by adding this to measurement.hpp (where Y is the type of UDT)

// Specialization of autoprefix_norm for UDTboost::units::measurement<Y> // See io.hpp. // This specialization is required to get autoprefix to work with this class. template<class Y> typename autoprefix_norm_impl<boost::units::measurement<Y>, true>::type autoprefix_norm(const boost::units::measurement<Y> & arg) { return autoprefix_norm_impl<Y, true>::call(arg); }

However this assumes that the class Y is convertible to double. autoprefix_norm_impl<T, true>::type appears to be always double. I am unclear if this is checked or is the responsibility or the user?

**Note:**See TracTickets for help on using tickets.