| 
									
										
										
										
											2004-07-01 18:38:02 +00:00
										 |  |  | //  (C) Copyright Herve Bronnimann 2004.
 | 
					
						
							| 
									
										
										
										
											2006-07-27 10:27:37 +00:00
										 |  |  | //
 | 
					
						
							|  |  |  | // Distributed under the Boost Software License, Version 1.0. (See accompanying
 | 
					
						
							|  |  |  | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 | 
					
						
							| 
									
										
										
										
											2004-07-01 18:38:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  Revision history: | 
					
						
							| 
									
										
										
										
											2004-07-01 20:16:38 +00:00
										 |  |  |    1 July 2004 | 
					
						
							|  |  |  |       Split the code into two headers to lessen dependence on | 
					
						
							|  |  |  |       Boost.tuple. (Herve) | 
					
						
							| 
									
										
										
										
											2004-07-01 18:38:02 +00:00
										 |  |  |    26 June 2004 | 
					
						
							|  |  |  |       Added the code for the boost minmax library. (Herve) | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef BOOST_ALGORITHM_MINMAX_HPP
 | 
					
						
							|  |  |  | #define BOOST_ALGORITHM_MINMAX_HPP
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* PROPOSED STANDARD EXTENSIONS:
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * minmax(a, b) | 
					
						
							|  |  |  |  * Effect: (b<a) ? std::make_pair(b,a) : std::make_pair(a,b); | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * minmax(a, b, comp) | 
					
						
							|  |  |  |  * Effect: comp(b,a) ? std::make_pair(b,a) : std::make_pair(a,b); | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-01 19:23:33 +00:00
										 |  |  | #include <boost/tuple/tuple.hpp> // for using pairs with boost::cref
 | 
					
						
							| 
									
										
										
										
											2004-07-22 13:37:47 +00:00
										 |  |  | #include <boost/ref.hpp>
 | 
					
						
							| 
									
										
										
										
											2004-07-01 18:38:02 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace boost { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   template <typename T> | 
					
						
							| 
									
										
										
										
											2004-07-01 19:23:33 +00:00
										 |  |  |   tuple< T const&, T const& > | 
					
						
							| 
									
										
										
										
											2004-07-01 18:38:02 +00:00
										 |  |  |   minmax(T const& a, T const& b) { | 
					
						
							| 
									
										
										
										
											2004-07-01 19:23:33 +00:00
										 |  |  |     return (b<a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b)); | 
					
						
							| 
									
										
										
										
											2004-07-01 18:38:02 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   template <typename T, class BinaryPredicate> | 
					
						
							| 
									
										
										
										
											2004-07-01 19:23:33 +00:00
										 |  |  |   tuple< T const&, T const& > | 
					
						
							| 
									
										
										
										
											2004-07-01 18:38:02 +00:00
										 |  |  |   minmax(T const& a, T const& b, BinaryPredicate comp) { | 
					
						
							| 
									
										
										
										
											2004-07-01 19:23:33 +00:00
										 |  |  |     return comp(b,a) ? make_tuple(cref(b),cref(a)) : make_tuple(cref(a),cref(b)); | 
					
						
							| 
									
										
										
										
											2004-07-01 18:38:02 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } // namespace boost
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-07-01 20:16:38 +00:00
										 |  |  | #endif // BOOST_ALGORITHM_MINMAX_HPP
 |