00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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
00025
00026 # if !defined (ACE_LACKS_MIN_MAX_TEMPLATES)
00027
00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00029
00030 template <class T>
00031 inline const T &
00032 ace_min (const T &t1, const T &t2)
00033 {
00034 return t2 > t1 ? t1 : t2;
00035 }
00036
00037 template <class T>
00038 inline const T &
00039 ace_max (const T &t1, const T &t2)
00040 {
00041 return t1 > t2 ? t1 : t2;
00042 }
00043
00044 template <class T>
00045 inline const T &
00046 ace_min (const T &t1, const T &t2, const T &t3)
00047 {
00048 return ace_min (ace_min (t1, t2), t3);
00049 }
00050
00051 template <class T>
00052 inline const T &
00053 ace_max (const T &t1, const T &t2, const T &t3)
00054 {
00055 return ace_max (ace_max (t1, t2), t3);
00056 }
00057
00058 template <class T>
00059 inline const T &
00060 ace_range (const T &min, const T &max, const T &val)
00061 {
00062 return ace_min (ace_max (min, val), max);
00063 }
00064
00065 ACE_END_VERSIONED_NAMESPACE_DECL
00066
00067 # else
00068
00069
00070 # define ace_min(a,b) (((b) > (a)) ? (a) : (b))
00071 # define ace_max(a,b) (((a) > (b)) ? (a) : (b))
00072 # define ace_range(a,b,c) (ace_min(ace_max((a), (c)), (b))
00073
00074 # endif
00075
00076 # define ACE_MIN(a,b) ace_min((a),(b))
00077 # define ACE_MAX(a,b) ace_max((a),(b))
00078 # define ACE_RANGE(a,b,c) ace_range((a),(b),(c))
00079
00080 #include "ace/post.h"
00081 #endif