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 80826 2008-03-04 14:51:23Z wotte $
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 #include /**/ "ace/config-all.h"
00021 
00022 # if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 #   pragma once
00024 # endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00027 
00028 template <class T>
00029 inline const T &
00030 ace_min (const T &t1, const T &t2)
00031 {
00032   return t2 > t1 ? t1 : t2;
00033 }
00034 
00035 template <class T>
00036 inline const T &
00037 ace_max (const T &t1, const T &t2)
00038 {
00039   return t1 > t2 ? t1 : t2;
00040 }
00041 
00042 template <class T>
00043 inline const T &
00044 ace_min (const T &t1, const T &t2, const T &t3)
00045 {
00046   return ace_min (ace_min (t1, t2), t3);
00047 }
00048 
00049 template <class T>
00050 inline const T &
00051 ace_max (const T &t1, const T &t2, const T &t3)
00052 {
00053   return ace_max (ace_max (t1, t2), t3);
00054 }
00055 
00056 template <class T>
00057 inline const T &
00058 ace_range (const T &min, const T &max, const T &val)
00059 {
00060   return ace_min (ace_max (min, val), max);
00061 }
00062 
00063 ACE_END_VERSIONED_NAMESPACE_DECL
00064 
00065 # define ACE_MIN(a,b)     ace_min((a),(b))
00066 # define ACE_MAX(a,b)     ace_max((a),(b))
00067 # define ACE_RANGE(a,b,c) ace_range((a),(b),(c))
00068 
00069 #include /**/ "ace/post.h"
00070 #endif  /* ACE_MIN_MAX_H */

Generated on Tue Feb 2 17:18:40 2010 for ACE by  doxygen 1.4.7