Answering to myself:
On Mar 12, 3:04 pm, alfC wrote:
Hi,
Sometimes it is difficult to make boost::units quantities with other
libraries. For example to have boost::accumulators mean work with
units, one has to specialize division by integer for quantities.
In this example the accumulators and units compiles out of the box but
gives an incorrect answer.
I found the solution, just add
#include
in this way the min/max function can initialize the default maximum/
minimum value, which is given by the numeric limits of the type.
Anyway, I would suggest to the authors of boost.units to include
limits.hpp by default in the core library in order *to avoid this
surprises*.
Or better yet, make the author of boost.accumulators to support
boost.units.
By the way I made boost accumulators to work with min, max (see above)
and mean by adding the below code. Variance, etc. is more difficult to
implement because boost.accumulators assumes that t*t is always of
type t.
namespace boost {namespace numeric{namespace functional{
using namespace boost::units;
template struct quantity_tag{};
template struct tag >{
typedef quantity_tag type;
};
template
struct average, void>{
typedef Left result_type;
result_type operator()(Left & left, Right & right) const{
return left/(typename Left::value_type)right;
}
};
}}}
Thanks,
Alfredo