25 #include "common/scummsys.h" 27 #include "common/type_traits.h" 42 #define IS_ALIGNED(value, alignment) \ 43 ((((size_t)value) & ((alignment) - 1)) == 0) 58 template<
typename T>
inline T
ABS(T x) {
return (x >= 0) ? x : -x; }
61 template<
typename T>
inline T
MIN(T a, T b) {
return (a < b) ? a : b; }
64 template<
typename T>
inline T
MAX(T a, T b) {
return (a > b) ? a : b; }
67 template<
typename T>
inline T
CLIP(T v, T amin, T amax)
69 #if !defined(RELEASE_BUILD) 76 if (v < amin)
return amin;
77 else if (v > amax)
return amax;
84 template<
typename T>
inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }
93 #define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0]))) 98 #define ARRAYEND(x) ((x) + ARRAYSIZE((x))) 103 template<
typename T,
size_t N>
inline void ARRAYCLEAR(T (&array) [N],
const T &value = T()) {
113 #if defined(__GNUC__) 114 # define SCUMMVM_CURRENT_FUNCTION __PRETTY_FUNCTION__ 115 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) 116 # define SCUMMVM_CURRENT_FUNCTION __func__ 117 #elif defined(_MSC_VER) 118 # define SCUMMVM_CURRENT_FUNCTION __FUNCTION__ 120 # define SCUMMVM_CURRENT_FUNCTION "<unknown>" 139 constexpr remove_reference_t<T> &&
move(T &&t) noexcept {
140 return static_cast<remove_reference_t<T> &&
>(t);
144 constexpr T&& forward(remove_reference_t<T> &&t) noexcept {
145 return static_cast<T &&
>(t);
149 constexpr T&& forward(remove_reference_t<T> &t) noexcept {
150 return static_cast<T &&
>(t);
156 template<
class T1,
class T2>
164 Pair(
const Pair &other) : first(other.first), second(other.second) {
170 Pair(
const T1 &first_,
const T2 &second_) : first(first_), second(second_) {
176 Pair(T1 &&first_,
const T2 &second_) : first(
Common::move(first_)), second(second_) {
179 Pair(
const T1 &first_, T2 &&second_) : first(first_), second(
Common::move(second_)) {
182 Pair &operator=(
const Pair &other) {
183 this->first = other.first;
184 this->second = other.second;
204 extern void hexdump(
const byte * data,
int len,
int bytesPerLine = 16,
int startOffset = 0);
void ARRAYCLEAR(T(&array) [N], const T &value=T())
Definition: util.h:103
bool parseBool(const String &val, bool &valAsBool)
void SWAP(T &a, T &b)
Definition: util.h:84
T CLIP(T v, T amin, T amax)
Definition: util.h:67
void hexdump(const byte *data, int len, int bytesPerLine=16, int startOffset=0)
Definition: algorithm.h:29
Common::String getHumanReadableBytes(uint64 bytes, const char *&unitsOut)
Out move(In first, In last, Out dst)
Definition: algorithm.h:109
T MIN(T a, T b)
Definition: util.h:61
T MAX(T a, T b)
Definition: util.h:64
T ABS(T x)
Definition: util.h:58