# min_element

### Synopsis

    template<
          typename Sequence
        , typename Pred = less<_1,_2>
        >
    struct min_element
    {
        typedef unspecified type;
    };

### Description

Finds the smallest element in the `Sequence`.

### Definition

    #include "boost/mpl/min_element.hpp"

### Parameters

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 semantics

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`. |

### Complexity

Linear. Zero comparisons if `Sequence` is empty, otherwise exactly `size<Sequence>::value - 1` comparisons.

### Example

    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