accumulate(timbre_topic_dist.begin(), timbre_topic_dist.end(), 0.0);
You do not want to be lazy and write 0.0 as 0, which will be interpreted by the compiler as an integer, which is used to infer the type of intermediate and final result of accumulate. For your reference, here attaches one of the multiple prototypes of accumulate:
template < typename _InputIterator, typename _Tp >Note that the partial result is stored in _Tp __init, which means even we explicitly use plus
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) {
for (; __first != __last; ++__first)
__init = __init + *__first;
return __init;
}
accumulate(timbre_topic_dist.begin(), timbre_topic_dist.end(), 0, // Wrong
plus
No comments:
Post a Comment