1 // (C) Copyright Herve Bronnimann 2004.
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)
9 Split the code into two headers to lessen dependence on
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:
21 * Effect: (b<a) ? std::make_pair(b,a) : std::make_pair(a,b);
24 * Effect: comp(b,a) ? std::make_pair(b,a) : std::make_pair(a,b);
28 #include <boost/config.hpp>
29 #include <boost/tuple/tuple.hpp> // for using pairs with boost::cref
30 #include <boost/ref.hpp>
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));
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));
48 #endif // BOOST_ALGORITHM_MINMAX_HPP