Boost logo

Boost Users :

Subject: Re: [Boost-users] accumulators doc typo?
From: Eric Niebler (eric_at_[hidden])
Date: 2011-07-06 13:32:49

On 7/6/2011 4:40 AM, Olaf Peter wrote:
> Hi,
> at
> in the example of section 'Droppable Accumulators' one can read
> // This will display "6 2 3"
> std::cout << sum(acc) << ' '
> << count(acc) << ' '
> << mean(acc);
> The text below says 'Note that at the point at which mean is dropped,
> sum is 3, count is 2, and therefore mean is 1.5'. After calculating my
> result is also 1.5 - the comment in the example isn't correct, isn't it?
> Probably the typo is in the upcoming release 1.47 too.

No, the comment in the docs is correct. Sum continues to accumulate, but
count does not --it was only added to the set to satisfy a dependency
from mean, which was dropped. So you end up with sum=6, count=2, and mean=3.

Note that if you change the declaration of acc in that example to:

  accumulator_set< double,
                   features< tag::sum, tag::count,
                             droppable<tag::mean> > > acc;

... the answer you get becomes "6 3 2". That is, once you have
explicitly asked for the count statistic, it no longer gets dropped
along with mean.


Eric Niebler
BoostPro Computing

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at