From f19f813537c7aea1c20749c914e756b54a9c3cf5 Mon Sep 17 00:00:00 2001 From: Igor Pavlov <87184205+ip7z@users.noreply.github.com> Date: Mon, 27 Dec 2021 00:00:00 +0000 Subject: '21.07' --- CPP/Common/Defs.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 CPP/Common/Defs.h (limited to 'CPP/Common/Defs.h') diff --git a/CPP/Common/Defs.h b/CPP/Common/Defs.h new file mode 100644 index 0000000..9adb88c --- /dev/null +++ b/CPP/Common/Defs.h @@ -0,0 +1,16 @@ +// Common/Defs.h + +#ifndef __COMMON_DEFS_H +#define __COMMON_DEFS_H + +template inline T MyMin(T a, T b) { return a < b ? a : b; } +template inline T MyMax(T a, T b) { return a > b ? a : b; } + +template inline int MyCompare(T a, T b) + { return a == b ? 0 : (a < b ? -1 : 1); } + +inline int BoolToInt(bool v) { return (v ? 1 : 0); } +inline unsigned BoolToUInt(bool v) { return (v ? (unsigned)1 : (unsigned)0); } +inline bool IntToBool(int v) { return (v != 0); } + +#endif -- cgit v1.2.3-55-g6feb