Boost logo

Boost :

From: Matthias Troyer (troyer_at_[hidden])
Date: 2007-01-30 17:03:09


Hi Eric,

On 30 Jan 2007, at 18:47, Eric Niebler wrote:
> Steven Watanabe wrote:
>> int main() {
>> accumulator_set<double, features<tag::mean,
>> droppable<tag::sum>
>>>> accum_set;
>> accum_set(1.0);
>> accum_set(2.0);
>> accum_set.drop<tag::sum>();
>> accum_set(3.0);
>> std::cout << mean(accum_set) << std::endl; //prints 1
>> }
>> This behavior can easily cause surprises. It must
>> be fixed to print 2. I'm not quite sure how to implement
>> it correctly. I think that probably you need to store the
>> result at the point that drop is called for external lookup
>> and continue to collect data for internal usage. Of course,
>> this only applies in the face of dependencies.
>
>
> The code is doing something a little unusual, but the result looks
> correct to me. What do you think the result should be, and why?

It should be 2. Note that if mean depends on sum, you cannot drop the
accumulation of sum. If I remember our design discussions correctly
then the "drop" would only drop the feature if it is not required for
another non-dropped feature.

Matthias


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk