1
// (C) Copyright Herve Bronnimann 2004.
2
// Use, modification and distribution are subject to the
3
// Boost Software License, Version 1.0. (See accompanying file
4
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
12
#include <boost/algorithm/minmax.hpp>
13
#include <boost/algorithm/minmax_element.hpp>
19
// Demonstrating minmax()
20
boost::tuple<int const&, int const&> result1 = boost::minmax(1, 0);
21
assert( result1.get<0>() == 0 );
22
assert( result1.get<1>() == 1 );
25
// Demonstrating minmax_element()
27
typedef list<int>::const_iterator iterator;
28
generate_n(front_inserter(L), 1000, rand);
29
pair< iterator, iterator > result2 = boost::minmax_element(L.begin(), L.end());
31
cout << "The smallest element is " << *(result2.first) << endl;
32
cout << "The largest element is " << *(result2.second) << endl;
34
assert( result2.first == std::min_element(L.begin(), L.end()) );
35
assert( result2.second == std::max_element(L.begin(), L.end()) );