Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / algorithm / minmax.hpp @ 2486

History | View | Annotate | Download (1.2 kB)

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