summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-11-07 14:33:52 +0000
committertruelight <truelight@openttd.org>2007-11-07 14:33:52 +0000
commitf5024f8c91899fe227483ef329b5998969b6bb23 (patch)
tree5e20fa9698f76d6f1edf92d0db2ddc5b9429a77f /src
parent5d196f4ac655f313351de4d39f249d9192a94967 (diff)
downloadopenttd-f5024f8c91899fe227483ef329b5998969b6bb23.tar.xz
(svn r11388) -Fix: postfix ++ returned new value, should (ofcourse) be old value (SmatZ)
-Fix: prefix ++ didn't exist, added it
Diffstat (limited to 'src')
-rw-r--r--src/helpers.hpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/helpers.hpp b/src/helpers.hpp
index f185eecec..4163be4ac 100644
--- a/src/helpers.hpp
+++ b/src/helpers.hpp
@@ -136,7 +136,15 @@ template <typename Tenum_t> struct TinyEnumT
}
/** postfix ++ operator on tiny type */
- FORCEINLINE TinyEnumT& operator ++ (int)
+ FORCEINLINE TinyEnumT operator ++ (int)
+ {
+ TinyEnumT org = *this;
+ if (++m_val >= end) m_val -= (storage_type)(end - begin);
+ return org;
+ }
+
+ /** prefix ++ operator on tiny type */
+ FORCEINLINE TinyEnumT& operator ++ ()
{
if (++m_val >= end) m_val -= (storage_type)(end - begin);
return *this;
@@ -208,8 +216,10 @@ public:
FORCEINLINE OverflowSafeInt operator - (const int other) const { OverflowSafeInt result = *this; result -= (int64)other; return result; }
FORCEINLINE OverflowSafeInt operator - (const uint other) const { OverflowSafeInt result = *this; result -= (int64)other; return result; }
- FORCEINLINE OverflowSafeInt& operator ++ (int) { return *this += 1; }
- FORCEINLINE OverflowSafeInt& operator -- (int) { return *this += -1; }
+ FORCEINLINE OverflowSafeInt& operator ++ () { return *this += 1; }
+ FORCEINLINE OverflowSafeInt& operator -- () { return *this += -1; }
+ FORCEINLINE OverflowSafeInt operator ++ (int) { OverflowSafeInt org = *this; *this += 1; return org; }
+ FORCEINLINE OverflowSafeInt operator -- (int) { OverflowSafeInt org = *this; *this += -1; return org; }
/**
* Safe implementation of multiplication.