Files
boost_algorithm/minmax/example/minmax_ex.cpp
Hervé Brönnimann 1e7aec2dee Finally adding the minmax library. Still allowing overlap with header
minmax.hpp from Eric Niebler, which should be resolved soon. --Herve'


[SVN r23225]
2004-06-28 08:36:43 +00:00

24 lines
618 B
C++

#include <list>
#include <algorithm>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <boost/minmax.hpp>
int main()
{
using namespace std;
list<int> L;
generate_n(front_inserter(L), 1000, rand);
typedef list<int>::const_iterator iterator;
pair< iterator, iterator > result = boost::minmax_element(L.begin(), L.end());
cout << "The smallest element is " << *(result.first) << endl;
cout << "The largest element is " << *(result.second) << endl;
assert( result.first == std::min_element(L.begin(), L.end()) );
assert( result.second == std::max_element(L.begin(), L.end()) );
}