How to check an empty boost::accumulators acc or not?
For example:
if (acc.isEmpty())//I don't know what function here
return 0;
else
return boost::accumulators::mean(acc).
Because if it's empty, i get NaN for boost::accumulators::mean(acc).
How to check an empty boost::accumulators acc or not?
For example:
if (acc.isEmpty())//I don't know what function here
return 0;
else
return boost::accumulators::mean(acc).
Because if it's empty, i get NaN for boost::accumulators::mean(acc).
You could use the accumulator count
:
if (boost::accumulators::count(acc) == 0)//I don't know what function here
return 0;
else
return boost::accumulators::mean(acc);
Alternatively, you could simply check if it is nan
by calling std::isnan
:
if(std::isnan(boost::accumulators::mean(acc))
return 0;
else
return boost::accumulators::mean(acc);