1[/ 2 Copyright 2010 Neil Groves 3 Distributed under the Boost Software License, Version 1.0. 4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5/] 6[section:max_element max_element] 7 8[heading Prototype] 9 10`` 11template<class ForwardRange> 12typename range_iterator<ForwardRange>::type 13max_element(ForwardRange& rng); 14 15template<class ForwardRange> 16typename range_iterator<const ForwardRange>::type 17max_element(const ForwardRange& rng); 18 19template<class ForwardRange, class BinaryPredicate> 20typename range_iterator<ForwardRange>::type 21max_element(ForwardRange& rng, BinaryPredicate pred); 22 23template<class ForwardRange, class BinaryPredicate> 24typename range_iterator<const ForwardRange>::type 25max_element(const ForwardRange& rng, BinaryPredicate pred); 26 27 28template< 29 range_return_value re, 30 class ForwardRange 31 > 32typename range_return<ForwardRange, re>::type 33max_element(ForwardRange& rng); 34 35template< 36 range_return_value_re, 37 class ForwardRange 38 > 39typename range_return<const ForwardRange, re>::type 40max_element(const ForwardRange& rng); 41 42template< 43 range_return_value re, 44 class ForwardRange, 45 class BinaryPredicate 46 > 47typename range_return<ForwardRange, re>::type 48max_element(ForwardRange& rng, BinaryPredicate pred); 49 50template< 51 range_return_value re, 52 class ForwardRange, 53 class BinaryPredicate 54 > 55typename range_return<const ForwardRange, re>::type 56max_element(const ForwardRange& rng, BinaryPredicate pred); 57`` 58 59[heading Description] 60 61The versions of `max_element` that return an iterator, return the iterator to the maximum value as determined by using `operator<` if a predicate is not supplied. Otherwise the predicate `pred` is used to determine the maximum value. The versions of `max_element` that return a `range_return`, defines `found` in the same manner as the returned iterator described above. 62 63[heading Definition] 64 65Defined in the header file `boost/range/algorithm/max_element.hpp` 66 67[heading Requirements] 68 69[*For the non-predicate versions:] 70 71* `ForwardRange` is a model of the __forward_range__ Concept. 72* `ForwardRange`'s value type is a model of the `LessThanComparableConcept`. 73 74[*For the predicate versions:] 75 76* `ForwardRange` is a model of the __forward_range__ Concept. 77* `BinaryPredicate` is a model of the `BinaryPredicateConcept`. 78* `ForwardRange`'s value type is convertible to both of `BinaryPredicate`'s argument types. 79 80[heading Complexity] 81 82Linear. Zero comparisons if `empty(rng)`, otherwise `distance(rng) - 1` comparisons. 83 84[endsect] 85 86 87