summaryrefslogtreecommitdiff
path: root/src/helpers.hpp
diff options
context:
space:
mode:
authortron <tron@openttd.org>2007-01-19 11:47:48 +0000
committertron <tron@openttd.org>2007-01-19 11:47:48 +0000
commit81e88a2a7c6bc999a46620906bed02d6b1e02814 (patch)
treeb99fe1407a3f7165356bacf607eb1e59804164a9 /src/helpers.hpp
parent659adc7c42cbad3220519b08e80f5c7cdcfd088a (diff)
downloadopenttd-81e88a2a7c6bc999a46620906bed02d6b1e02814.tar.xz
(svn r8276) -Fix
Change the signature of Swap() to be less error prone, i.e. pass the variables to be swapped by reference instead of passing pointers to the variables. Just do Swap(x, y) instead of Swap(&x, &y). This prevents accidents when the variables are pointers.
Diffstat (limited to 'src/helpers.hpp')
-rw-r--r--src/helpers.hpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/helpers.hpp b/src/helpers.hpp
index 14b6056b3..2fed51582 100644
--- a/src/helpers.hpp
+++ b/src/helpers.hpp
@@ -30,14 +30,13 @@ template <typename T> FORCEINLINE T* ReallocT(T* t_ptr, size_t num_elements)
return t_ptr;
}
-/** type safe swap operation */
-template <typename T> void SwapT(T *a, T *b);
-template <typename T> FORCEINLINE void SwapT(T *a, T *b)
+/** type safe swap operation */
+template<typename T> void Swap(T& a, T& b)
{
- T t = *a;
- *a = *b;
- *b = t;
+ T t = a;
+ a = b;
+ b = t;
}
@@ -141,11 +140,6 @@ template <typename Tenum_t> struct TinyEnumT
}
};
-template <typename Tenum_t> FORCEINLINE void SwapT(TinyEnumT<Tenum_t> *a, TinyEnumT<Tenum_t> *b)
-{
- SwapT(&a->m_val, &b->m_val);
-}
-
template <typename T> FORCEINLINE T ClrBitT(T t, int bit_index)
{
int val = t;