1

私はBoostライブラリが初めてです。距離ベクトル (タイプ ) の最小値、最大値、平均値、および分散を計算できるプログラムが必要でstd::vector < double >、次のコードを書きました。

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));でエラーを出し、それは言う

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));

誰かがこのエラーを解決する方法についてヒントを教えてもらえますか?

4

1 に答える 1

2

問題は、boost::mpl::placeholders::_1MPL を使用しない内部コードを使用していることです。代わりに、ただ言って_1ください。

于 2016-11-26T05:04:24.237 に答える