Added multi-type EQEmu::ValueWithin function

This commit is contained in:
Uleat 2016-05-30 03:32:01 -04:00
parent ecc9e41ab2
commit b155a603aa

View File

@ -1,5 +1,6 @@
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2014 EQEMu Development Team (http://eqemulator.net)
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -15,34 +16,40 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef COMMON_DATA_VERIFICATION_H
#define COMMON_DATA_VERIFICATION_H
#include <algorithm>
namespace EQEmu
{
template <typename T>
T Clamp(const T& value, const T& lower, const T& upper) {
template <typename T>
T Clamp(const T& value, const T& lower, const T& upper) {
return std::max(lower, std::min(value, upper));
}
}
template <typename T>
T ClampLower(const T& value, const T& lower) {
template <typename T>
T ClampLower(const T& value, const T& lower) {
return std::max(lower, value);
}
}
template <typename T>
T ClampUpper(const T& value, const T& upper) {
template <typename T>
T ClampUpper(const T& value, const T& upper) {
return std::min(value, upper);
}
}
template <typename T>
bool ValueWithin(const T& value, const T& lower, const T& upper) {
template <typename T>
bool ValueWithin(const T& value, const T& lower, const T& upper) {
return value >= lower && value <= upper;
}
}
}
template <typename T1, typename T2, typename T3>
bool ValueWithin(const T1& value, const T2& lower, const T3& upper) {
return value >= (T1)lower && value <= (T1)upper;
}
#endif
} /*EQEmu*/
#endif /*COMMON_DATA_VERIFICATION_H*/