.. Algorithms/Querying Algorithms//min_element |80 min_element =========== Synopsis -------- .. parsed-literal:: template< typename Sequence , typename Pred = less<_1,_2> > struct min_element { typedef |unspecified| type; }; Description ----------- Returns an iterator to the smallest element in ``Sequence``. Header ------ .. parsed-literal:: #include Parameters ---------- +---------------+-------------------------------+-----------------------------------+ | Parameter | Requirement | Description | +===============+===============================+===================================+ |``Sequence`` | |Forward Sequence| | A sequence to be searched. | +---------------+-------------------------------+-----------------------------------+ | ``Pred`` | Binary |Lambda Expression| | A comparison criteria. | +---------------+-------------------------------+-----------------------------------+ Expression semantics -------------------- For any |Forward Sequence| ``s`` and binary |Lambda Expression| ``pred``: .. parsed-literal:: typedef min_element::type i; :Return type: |Forward Iterator|. :Semantics: ``i`` is the first iterator in |begin/end| such that for every iterator ``j`` in |begin/end|, .. parsed-literal:: apply< pred, deref::type, deref::type >::type::value == false Complexity ---------- Linear. Zero comparisons if ``s`` is empty, otherwise exactly ``size::value - 1`` comparisons. Example ------- .. parsed-literal:: typedef vector types; typedef min_element< transform_view< types,sizeof_<_1> > >::type iter; BOOST_MPL_ASSERT(( is_same< deref::type, bool> )); See also -------- |Querying Algorithms|, |max_element|, |find_if|, |upper_bound|, |find|