1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/algorithm/minmax.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,47 @@
1.4 +// (C) Copyright Herve Bronnimann 2004.
1.5 +// Use, modification and distribution are subject to the
1.6 +// Boost Software License, Version 1.0. (See accompanying file
1.7 +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
1.8 +
1.9 +/*
1.10 + Revision history:
1.11 + 1 July 2004
1.12 + Split the code into two headers to lessen dependence on
1.13 + Boost.tuple. (Herve)
1.14 + 26 June 2004
1.15 + Added the code for the boost minmax library. (Herve)
1.16 +*/
1.17 +
1.18 +#ifndef BOOST_ALGORITHM_MINMAX_HPP
1.19 +#define BOOST_ALGORITHM_MINMAX_HPP
1.20 +
1.21 +/* PROPOSED STANDARD EXTENSIONS:
1.22 + *
1.23 + * minmax(a, b)
1.24 + * Effect: (b<a) ? std::make_pair(b,a) : std::make_pair(a,b);
1.25 + *
1.26 + * minmax(a, b, comp)
1.27 + * Effect: comp(b,a) ? std::make_pair(b,a) : std::make_pair(a,b);
1.28 + *
1.29 + */
1.30 +
1.31 +#include <boost/tuple/tuple.hpp> // for using pairs with boost::cref
1.32 +#include <boost/ref.hpp>
1.33 +
1.34 +namespace boost {
1.35 +
1.36 + template <typename T>
1.37 + tuple< T const&, T const& >
1.38 + minmax(T const& a, T const& b) {
1.39 + return (b<a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b));
1.40 + }
1.41 +
1.42 + template <typename T, class BinaryPredicate>
1.43 + tuple< T const&, T const& >
1.44 + minmax(T const& a, T const& b, BinaryPredicate comp) {
1.45 + return comp(b,a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b));
1.46 + }
1.47 +
1.48 +} // namespace boost
1.49 +
1.50 +#endif // BOOST_ALGORITHM_MINMAX_HPP