From 1ac5d153fb683d6f37168136847784b6e08013a8 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Thu, 21 Nov 2024 23:55:51 +0200 Subject: [PATCH] Correct inc/dec operator overloads --- Tactical/Overhead Types.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/Tactical/Overhead Types.h b/Tactical/Overhead Types.h index 40d23a03b..65e6ec04c 100644 --- a/Tactical/Overhead Types.h +++ b/Tactical/Overhead Types.h @@ -415,6 +415,16 @@ typedef struct SoldierID const SOLDIERTYPE* operator->() const { return MercPtrs[i]; } inline operator SOLDIERTYPE* () { return MercPtrs[i]; } inline operator const SOLDIERTYPE*() const { return MercPtrs[i]; } + inline SoldierID &operator++() + { + i++; + return *this; + } + inline SoldierID &operator--() + { + i--; + return *this; + } } SoldierID; inline bool operator==(const SoldierID lhs, const SoldierID rhs) { return lhs.i == rhs.i; } @@ -475,17 +485,6 @@ inline SoldierID operator+(const SoldierID lhs, const UINT16 rhs) { return Soldi inline SoldierID operator+(const unsigned int lhs, const SoldierID rhs) { return SoldierID{ static_cast(lhs + rhs.i) }; } inline SoldierID operator+(const INT16 lhs, const SoldierID rhs) { return SoldierID{ static_cast(lhs + rhs.i) }; } -inline SoldierID operator--(SoldierID lhs) -{ - lhs.i -= 1; - return lhs; -} - -inline SoldierID operator++(SoldierID lhs) -{ - lhs.i += 1; - return lhs; -} //TODO: Change this to constexpr after SoldierID is ready and the user defined constructor from uint16 is not needed anymore. inline constexpr SoldierID NOBODY{ TOTAL_SOLDIERS };