从 accumulator_set 中删除或修改 accumulators::tag

Delete or modify an accumulators::tag from accumulator_set

在 boost 中,是否可以从 accumulator_set 中动态删除给定的 boost::accumulators::tag

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;

或者,或者,将一个新的 boost::accumulators::stats 容器分配给 accumulator_set,我可以在其中从字符串中指定一些 boost::accumulators::tag。比如字符串是min,max,mean,那么我想新建一个 accumulator_set<double,bost::accumulators::stats<boost::accumulators::tag::min,boost::accumulators::tag::max,boost::accumulators::tag::mean>> acc.

提前感谢您的建议。

简答:没有。

更长的答案:通过类型擦除和大量模板元编程,一切皆有可能。

如果您觉得您确实需要这个,请开始使用例如 .Boost Function 或 Boost Erasure,或者 post 一个具有更详细目标和卡住位置的问题。 "assign a new boost::accumulators::stats container to the accumulator_set where I can specify some boost::accumulators::tag from a string"的解读方式太多了

如果组合有限,Boost Variant 是您的朋友。否则,Boost Any 和...许多特殊情况以提取结果。这将是一个/很多/的元编程虽然

现实中,如果你负担得起,为什么不使用"max featured"累加器组,按照文本配置只公开一次呢?你会在运行时做比需要更多的工作,但你会在开发方面节省大量工作。