Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Min_Max.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   Min_Max.h
00006  *
00007  *  $Id: Min_Max.h,v 1.1.1.3 2001/12/04 14:33:04 chad Exp $
00008  *
00009  * Define an appropriate set of min()/max() functions using templates.
00010  *
00011  *
00012  *  @author Derek Dominish <Derek.Dominish@Australia.Boeing.com>
00013  */
00014 //=============================================================================
00015 
00016 #ifndef ACE_MIN_MAX_H
00017 #define ACE_MIN_MAX_H
00018 #include "ace/pre.h"
00019 
00020 # if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 #   pragma once
00022 # endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 # if !defined (ACE_LACKS_MIN_MAX_TEMPLATES)
00025 template <class T>
00026 inline const T &
00027 ace_min (const T &t1, const T &t2)
00028 {
00029   return t2 > t1 ? t1 : t2;
00030 }
00031 
00032 template <class T>
00033 inline const T &
00034 ace_max (const T &t1, const T &t2)
00035 {
00036   return t1 > t2 ? t1 : t2;
00037 }
00038 
00039 template <class T>
00040 inline const T &
00041 ace_min (const T &t1, const T &t2, const T &t3)
00042 {
00043   return ace_min (ace_min (t1, t2), t3);
00044 }
00045 
00046 template <class T>
00047 inline const T &
00048 ace_max (const T &t1, const T &t2, const T &t3)
00049 {
00050   return ace_max (ace_max (t1, t2), t3);
00051 }
00052 
00053 template <class T>
00054 inline const T &
00055 ace_range (const T &min, const T &max, const T &val)
00056 {
00057   return ace_min (ace_max (min, val), max);
00058 }
00059 # else
00060 // These macros should only be used if a C++ compiler can't grok the
00061 // inline templates
00062 #  define ace_min(a,b)      (((b) > (a)) ? (a) : (b))
00063 #  define ace_max(a,b)      (((a) > (b)) ? (a) : (b))
00064 #  define ace_range(a,b,c)  (ace_min(ace_max((a), (c)), (b))
00065 
00066 # endif /* ACE_LACKS_MIN_MAX_TEMPLATES */
00067 
00068 # define ACE_MIN(a,b)     ace_min((a),(b))
00069 # define ACE_MAX(a,b)     ace_max((a),(b))
00070 # define ACE_RANGE(a,b,c) ace_range((a),(b),(c))
00071 
00072 #include "ace/post.h"
00073 #endif  /* ACE_MIN_MAX_H */

Generated on Mon Jun 16 11:20:26 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002