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)
5
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)
13*/
14
15#ifndef BOOST_ALGORITHM_MINMAX_HPP
16#define BOOST_ALGORITHM_MINMAX_HPP
17
18/* PROPOSED STANDARD EXTENSIONS:
19 *
20 * minmax(a, b)
21 * Effect: (b<a) ? std::make_pair(b,a) : std::make_pair(a,b);
22 *
23 * minmax(a, b, comp)
24 * Effect: comp(b,a) ? std::make_pair(b,a) : std::make_pair(a,b);
25 *
26 */
27
28#include <boost/config.hpp>
29#include <boost/tuple/tuple.hpp> // for using pairs with boost::cref
30#include <boost/ref.hpp>
31
32namespace boost {
33
34 template <typename T>
35 tuple< T const&, T const& >
36 minmax(T const& a, T const& b) {
37 return (b<a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b));
38 }
39
40 template <typename T, class BinaryPredicate>
41 tuple< T const&, T const& >
42 minmax(T const& a, T const& b, BinaryPredicate comp) {
43 return comp(b,a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b));
44 }
45
46} // namespace boost
47
48#endif // BOOST_ALGORITHM_MINMAX_HPP
49

source code of boost/libs/algorithm/include/boost/algorithm/minmax.hpp