
On 14 May 2010 15:13, Boris Schaeling
A reader of my book noticed that the sample program at http://en.highscore.de/cpp/boost/src/4.2.8/main.cpp which uses a combiner to return the smallest value of all slot values is buggy. The combiner's implementation is rather simple as iterators are simply forwarded to std::min_element():
template <typename T> struct min_element { typedef T result_type;
template <typename InputIterator> T operator()(InputIterator first, InputIterator last) const { return *std::min_element(first, last); } };
Your choice of typename here has me worried, since std::min_element requires ForwardIterators, not InputIterators. That's also the explanation for your last code example; it uses the iterators in a way not allowed for input iterators.