boost аккумулятор_set: ожидать первичного выражения

Я новичок в библиотеке 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));

Может ли кто-нибудь дать мне подсказку, как решить эту ошибку?

1

Решение

Проблема в том, что вы используете boost::mpl::placeholders::_1 внутри кода, который не использует MPL. Вместо этого просто скажи _1,

2

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector