Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.



      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  
SequenceA model of Forward SequenceA sequence to be searched.
PredA model of binary Predicate [Lambda Expression]A comparison criteria.

Expression semantics

 Expression  Expression type  Precondition  Semantics  Postcondition 
typedef min_element< Sequence,Pred >::type i;A model of Forward Iteratori 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));

See also

Algorithms, max_element, upper_bound, lower_bound

Table of Contents
Last edited March 10, 2003 6:05 am