...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
template< typename Sequence , typename Pred = less<_1,_2> > struct min_element { typedef unspecified type; };
Finds the smallest element in the Sequence
.
#include "boost/mpl/min_element.hpp"
Parameter | Requirement | Description |
---|---|---|
Sequence | A model of Forward Sequence | A sequence to be searched. |
Pred | A model of binary Predicate [Lambda Expression] | A comparison criteria. |
Expression | Expression type | Precondition | Semantics | Postcondition |
---|---|---|---|---|
typedef min_element< Sequence,Pred >::type i; | A model of Forward Iterator | i is the first iterator in [begin<Sequence>::type, end<Sequence>::type) such that for every iterator j in [begin<Sequence>::type, end<Sequence>::type) , apply< lambda<Pred>::type, j::type, i::type >::type::value == false . |
Linear. Zero comparisons if Sequence
is empty, otherwise exactly size<Sequence>::value - 1
comparisons.
typedef vector<bool,char[50],long,double> types; typedef min_element< transform_view< types,sizeof_<_1> > >::type iter;BOOST_STATIC_ASSERT((distance< begin<types>::type,iter >::type::value == 0)); BOOST_STATIC_ASSERT(sizeof(deref<iter>::type) == sizeof(bool));
Algorithms, max_element
, upper_bound
, lower_bound