c++boostaccumulator

Delete or modify an accumulators::tag from accumulator_set


In boost, is it possible to delete a given boost::accumulators::tag dynamically from an accumulator_set?

typedef boost::accumulators::features <
    boost::accumulators::tag::count,
    boost::accumulators::tag::max,
    boost::accumulators::tag::min,
    boost::accumulators::tag::mean,
    boost::accumulators::tag::variance,
    boost::accumulators::tag::skewness,
    boost::accumulators::tag::kurtosis,
> StatisticalFeatures;
accumulator_set<double, boost::accumulators::stats<StatisticalFeatures>> acc;

Or, alternatively, assign a new boost::accumulators::stats container to the accumulator_set where I can specify some boost::accumulators::tag from a string. For example, if the string is min,max,mean, then I want to create a new accumulator_set<double,bost::accumulators::stats<boost::accumulators::tag::min,boost::accumulators::tag::max,boost::accumulators::tag::mean>> acc.

Thanks in advance for your advice.


Solution

  • Short answer: no.

    Longer answer: with type erasure and a lot of template metaprogramming, everything is possible.

    If you feel you really need this, start out using e.g .Boost Function or Boost Erasure, or post a question with a more detailed goal and the place where you are stuck. There are too many ways in which "assign a new boost::accumulators::stats container to the accumulator_set where I can specify some boost::accumulators::tag from a string" can be interpreted.

    If the combinations are limited, Boost Variant is your friend. Otherwise, Boost Any and ... many special cases to extract the results. This would be a /lot/ of meta programming though

    In reality, if you can afford it, why not use the "max featured" accumulator set, and only disclose the once according to the text configuration? You'd do more work than needed at runtime, but you'd save a huge effort on the development side.