首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >boost accumulator_set: expect主表达式

boost accumulator_set: expect主表达式
EN

Stack Overflow用户
提问于 2016-11-26 03:46:23
回答 1查看 153关注 0票数 1

我是一个促进图书馆发展的新人。我想要一个程序,可以计算距离向量的最小、最大、平均和方差(类型为std::vector < double >),我编写了以下代码

代码语言:javascript
复制
std::vector < double > dist_err;
// ... do something with dist_err
boost::accumulators::accumulator_set
< 
    double, 
    boost::accumulators::stats
    <
        boost::accumulators::tag::min , 
        boost::accumulators::tag::max ,
        boost::accumulators::tag::mean,
        boost::accumulators::tag::variance
    > 
> stat_acc;
std::for_each(dist_err.begin(), dist_err.end(), boost::bind < void > (boost::ref(stat_acc), boost::mpl::placeholders::_1));
std::cout << "min[distance error]: " << boost::accumulators::min      (stat_acc) << std::endl;
std::cout << "MAX[distance error]: " << boost::accumulators::max      (stat_acc) << std::endl;
std::cout << "  E[distance error]: " << boost::accumulators::mean     (stat_acc) << std::endl;
std::cout << "VAR[distance error]: " << boost::accumulators::variance (stat_acc) << std::endl;

但是程序在std::for_each(dist_err.begin(), dist_err.end(), boost::bind < void > (boost::ref(stat_acc), boost::mpl::placeholders::_1));行给了我一个错误,它说

代码语言:javascript
复制
error: expected primary-expression before ')' token
std::for_each(dist_err.begin(), dist_err.end(), boost::bind < void > (boost::ref(stat_acc), boost::mpl::placeholders::_1));

有人能给我一些关于如何解决这个错误的提示吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-26 05:04:24

问题是,您在代码中使用的是boost::mpl::placeholders::_1,它不使用MPL。相反,只需说_1

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40814703

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档