I am a new to Boost library. I want a program that could compute the min, max, mean and variance of a distance vector (of type std::vector < double >
) and I wrote the following code
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;
But the program gives me an error at line std::for_each(dist_err.begin(), dist_err.end(), boost::bind < void > (boost::ref(stat_acc), boost::mpl::placeholders::_1));
and it says
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));
Could someone please give me some hint on how to solve this error?
The problem is you are using boost::mpl::placeholders::_1
inside code which doesn't use MPL. Instead, just say _1
.