fix doc example typo
[boost.git] / boost / algorithm / minmax.hpp
blob053a7d60ae0be25088042678f303ae1b3d1ee18c
1 // (C) Copyright Herve Bronnimann 2004.
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 /*
7 Revision history:
8 1 July 2004
9 Split the code into two headers to lessen dependence on
10 Boost.tuple. (Herve)
11 26 June 2004
12 Added the code for the boost minmax library. (Herve)
15 #ifndef BOOST_ALGORITHM_MINMAX_HPP
16 #define BOOST_ALGORITHM_MINMAX_HPP
18 /* PROPOSED STANDARD EXTENSIONS:
20 * minmax(a, b)
21 * Effect: (b<a) ? std::make_pair(b,a) : std::make_pair(a,b);
23 * minmax(a, b, comp)
24 * Effect: comp(b,a) ? std::make_pair(b,a) : std::make_pair(a,b);
28 #include <boost/tuple/tuple.hpp> // for using pairs with boost::cref
29 #include <boost/ref.hpp>
31 namespace boost {
33 template <typename T>
34 tuple< T const&, T const& >
35 minmax(T const& a, T const& b) {
36 return (b<a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b));
39 template <typename T, class BinaryPredicate>
40 tuple< T const&, T const& >
41 minmax(T const& a, T const& b, BinaryPredicate comp) {
42 return comp(b,a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b));
45 } // namespace boost
47 #endif // BOOST_ALGORITHM_MINMAX_HPP