[英]Using empty boost::accumulators
How to check an empty boost::accumulators acc or not? 如何检查空的boost :: accumulators acc是否?
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). 因为如果它是空的,我会得到NaN用于boost :: accumulators :: mean(acc)。
You could use the accumulator count
: 您可以使用累加器
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
: 另外,您可以通过调用
std::isnan
来简单地检查它是否为nan
:
if(std::isnan(boost::accumulators::mean(acc))
return 0;
else
return boost::accumulators::mean(acc);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.