diff options
author | frosch <frosch@openttd.org> | 2010-01-16 14:22:19 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-01-16 14:22:19 +0000 |
commit | 6465f02fba984e169c904cccf89fd1417ee2f45b (patch) | |
tree | 1708196e69bfc12f14fe47743e26be39c5c1ae65 /src/misc | |
parent | 84ece021fde4850b4755b81bb6886ffced6b7020 (diff) | |
download | openttd-6465f02fba984e169c904cccf89fd1417ee2f45b.tar.xz |
(svn r18826) -Codechange: Unifiy return value of (SmallArray|FixedSizeArray)::(Append|AppendC) with other containers. (skidd13)
Diffstat (limited to 'src/misc')
-rw-r--r-- | src/misc/array.hpp | 6 | ||||
-rw-r--r-- | src/misc/fixedsizearray.hpp | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/misc/array.hpp b/src/misc/array.hpp index e4cf19408..78dd0098f 100644 --- a/src/misc/array.hpp +++ b/src/misc/array.hpp @@ -35,7 +35,7 @@ protected: SubArray& s = data[super_size - 1]; if (!s.IsFull()) return s; } - return data.AppendC(); + return *data.AppendC(); } public: @@ -56,9 +56,9 @@ public: /** return true if array is full */ FORCEINLINE bool IsFull() { return data.IsFull() && data[N - 1].IsFull(); } /** allocate but not construct new item */ - FORCEINLINE T& Append() { return FirstFreeSubArray().Append(); } + FORCEINLINE T *Append() { return FirstFreeSubArray().Append(); } /** allocate and construct new item */ - FORCEINLINE T& AppendC() { return FirstFreeSubArray().AppendC(); } + FORCEINLINE T *AppendC() { return FirstFreeSubArray().AppendC(); } /** indexed access (non-const) */ FORCEINLINE T& operator [] (uint index) { diff --git a/src/misc/fixedsizearray.hpp b/src/misc/fixedsizearray.hpp index 435dfad79..5d52c2881 100644 --- a/src/misc/fixedsizearray.hpp +++ b/src/misc/fixedsizearray.hpp @@ -93,9 +93,9 @@ public: /** return true if array is empty */ FORCEINLINE bool IsEmpty() const { return Length() <= 0; }; /** add (allocate), but don't construct item */ - FORCEINLINE T& Append() { assert(!IsFull()); return data[SizeRef()++]; } + FORCEINLINE T *Append() { assert(!IsFull()); return &data[SizeRef()++]; } /** add and construct item using default constructor */ - FORCEINLINE T& AppendC() { T& item = Append(); new(&item)T; return item; } + FORCEINLINE T *AppendC() { T *item = Append(); new(item)T; return item; } /** return item by index (non-const version) */ FORCEINLINE T& operator [] (uint index) { assert(index < Length()); return data[index]; } /** return item by index (const version) */ |