• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1.. Algorithms/Querying Algorithms//max_element |90
2
3max_element
4===========
5
6Synopsis
7--------
8
9.. parsed-literal::
10
11    template<
12          typename Sequence
13        , typename Pred = less<_1,_2>
14        >
15    struct max_element
16    {
17        typedef |unspecified| type;
18    };
19
20
21
22Description
23-----------
24
25Returns an iterator to the largest element in ``Sequence``.
26
27
28Header
29------
30
31.. parsed-literal::
32
33    #include <boost/mpl/max_element.hpp>
34
35
36Parameters
37----------
38
39+---------------+-------------------------------+-----------------------------------+
40| Parameter     | Requirement                   | Description                       |
41+===============+===============================+===================================+
42|``Sequence``   | |Forward Sequence|            | A sequence to be searched.        |
43+---------------+-------------------------------+-----------------------------------+
44| ``Pred``      | Binary |Lambda Expression|    | A comparison criteria.            |
45+---------------+-------------------------------+-----------------------------------+
46
47
48Expression semantics
49--------------------
50
51
52For any |Forward Sequence| ``s`` and binary |Lambda Expression| ``pred``:
53
54
55.. parsed-literal::
56
57    typedef max_element<s,pred>::type i;
58
59:Return type:
60    |Forward Iterator|.
61
62:Semantics:
63    ``i`` is the first iterator in |begin/end<s>| such that for every iterator ``j``
64    in |begin/end<s>|,
65
66    .. parsed-literal::
67
68        apply< pred, deref<i>::type, deref<j>::type >::type::value == false
69
70
71Complexity
72----------
73
74Linear. Zero comparisons if ``s`` is empty, otherwise exactly ``size<s>::value - 1``
75comparisons.
76
77
78Example
79-------
80
81.. parsed-literal::
82
83    typedef vector<bool,char[50],long,double> types;
84    typedef max_element<
85          transform_view< types,sizeof_<_1> >
86        >::type iter;
87
88    BOOST_MPL_ASSERT(( is_same< deref<iter::base>::type, char[50]> ));
89
90
91See also
92--------
93
94|Querying Algorithms|, |min_element|, |find_if|, |upper_bound|, |find|
95
96
97.. copyright:: Copyright �  2001-2009 Aleksey Gurtovoy and David Abrahams
98   Distributed under the Boost Software License, Version 1.0. (See accompanying
99   file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
100