mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 06:21:28 +00:00
Added multi-type EQEmu::ValueWithin function
This commit is contained in:
parent
ecc9e41ab2
commit
b155a603aa
@ -1,5 +1,6 @@
|
|||||||
/* EQEMu: Everquest Server Emulator
|
/* 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
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -15,14 +16,15 @@
|
|||||||
along with this program; if not, write to the Free Software
|
along with this program; if not, write to the Free Software
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef COMMON_DATA_VERIFICATION_H
|
#ifndef COMMON_DATA_VERIFICATION_H
|
||||||
#define COMMON_DATA_VERIFICATION_H
|
#define COMMON_DATA_VERIFICATION_H
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
namespace EQEmu
|
namespace EQEmu
|
||||||
{
|
{
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T Clamp(const T& value, const T& lower, const T& upper) {
|
T Clamp(const T& value, const T& lower, const T& upper) {
|
||||||
return std::max(lower, std::min(value, upper));
|
return std::max(lower, std::min(value, upper));
|
||||||
@ -43,6 +45,11 @@ bool ValueWithin(const T& value, const T& lower, const T& upper) {
|
|||||||
return value >= lower && value <= 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*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user