Boost logo

Boost Users :

Subject: Re: [Boost-users] [units] How to use units with UDT's: was How to make is_arithmetic true for a UDT
From: John Maddock (boost.regex_at_[hidden])
Date: 2012-07-12 13:00:58


> Well I finally managed to string enough neurons together to write
>
> // Specialization of autoprefix_norm for boost::units::measurement<Y>
> // See io.hpp
> // This 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);
> }
>
> and that does the trick :-))

Hold on a second, doesn't that just tell Units to treat all T's as if
they're double? Or is the type measurement your type?

In any case autoprefix_norm_impl<T, true>::type appears to be always double,
what happens if the UDT can't fit in a double?

There's also a distinct lack of documentation on this, this page:
http://www.boost.org/doc/libs/1_50_0/doc/html/boost_units/Reference.html
mentions autoprefix_norm, but doesn't say what an overload should actually
do :-(

> quantity<length, measurement<double> >
> biglen(measurement<double>(12345.0,123.0)*meters); autoscaled =
> 12.345(+/-0.123) km
>
> so many thanks.
>
> But I'm still not clear when I could need the non-narrowing conversion in
> Boost.units quantity.hpp.

Nor me, there's no docs on this at all.

I think it would help a great deal if the Units guys could chime in here
and/or and a section on using Units with UDT's.

John.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net