【问题标题】:boost::accumulator: which operators for sample_type?boost::accumulator: sample_type 的哪些运算符?
【发布时间】:2014-10-27 16:42:48
【问题描述】:

我想使用 boost::accumulator 来定义我的自定义类的移动平均值:

boost::accumulators::accumulator_set<MySample, boost::accumulators::stats<boost::accumulators::tag::rolling_mean> >

我的问题是我的示例是用户定义的类(另一个库的向量实现)。

我看到in this post 可以为std::vectors 定义累加器,但它没有指定必须重载哪个运算符,因为它使用boost/accumulators/numeric/functional/vector.hpp 重载它们。

如果我想将累加器与用户定义的示例类一起使用,我必须重载哪个运算符以及如何重载?

【问题讨论】:

  • 你弄明白了吗?

标签: c++ boost vector operator-overloading boost-accumulators


【解决方案1】:

答案会因您使用的统计数据而异,遗憾的是,这些都没有得到很好的记录。我能给出的最佳答案是尝试编译它,查看错误消息,添加所需的运算符,冲洗,重复直到一切正常。 :-/

【讨论】:

  • 是的,我也想这样做,但是当模板出现编译错误时,编译器消息可能很难阅读(对我来说),我无法轻松找出问题所在可。反正我会试试的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-19
  • 2011-02-23
  • 2021-12-23
  • 2014-11-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多