Why does std::max_element require a ForwardIterator?
问题 The C++ standard library's max_element algorithm requires the iterators passed as inputs to model ForwardIterator . My understanding is that ForwardIterator refines InputIterator by specifying that you can use a ForwardIterator to iterate over the same range multiple times. Therefore, multi-pass algorithms require ForwardIterator s. However, max_element is not a multi-pass algorithm - it is sufficient to iterate over a range once to determine its maximum element. So why does max_element need