|
Boost Users : |
Subject: [Boost-users] punits][accumulators] buggy behavior for min accumulator of quantities
From: alfC (alfredo.correa_at_[hidden])
Date: 2011-03-12 18:04:39
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.
#include<boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/min.hpp> // or other stat
features
#include <boost/accumulators/statistics/max.hpp> // or other stat
features
#include<boost/units/systems/si.hpp>
#include<boost/units/io.hpp>
using namespace boost::accumulators;
using namespace boost::units;
int main(){
accumulator_set<quantity<si::time>, features<tag::min, tag::max> > a;
a(2.1*si::second);
a(2.0*si::second);
a(4.1*si::second);
std::cout
<< extract::min(a)<< " "
<< extract::max(a)<< std::endl
;
return 0;
}
It prints: 0 s 4.1 s
instead of: 2.1 s 4.1 s
So, it seems that the min extractor fails for quantities. I would like
to know if there is a way to correctly specialize "min" for
quantities. (By the way, std::min for quantities works fine).
However the behavior is unfortunate in the first place. Regardless of
the solution I would label this as a bug of one of the two libraries.
Thank you,
Alfredo
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