Changeset - r19523:0a961bdbee52
[Not reviewed]
master
0 1 0
frosch - 12 years ago 2012-07-29 20:02:25
frosch@openttd.org
(svn r24448) -Fix [FS#5255]: Copy constructor and assignment operator cannot be implicit template specialisations. (adf88)
1 file changed with 34 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/core/smallvec_type.hpp
Show inline comments
 
@@ -39,21 +39,39 @@ public:
 
	 * Copy constructor.
 
	 * @param other The other vector to copy.
 
	 */
 
	SmallVector(const SmallVector &other) : data(NULL), items(0), capacity(0)
 
	{
 
		this->Assign(other);
 
	}
 

	
 
	/**
 
	 * Generic copy constructor.
 
	 * @param other The other vector to copy.
 
	 */
 
	template <uint X>
 
	SmallVector(const SmallVector<T, X> &other) : data(NULL), items(0), capacity(0)
 
	{
 
		MemCpyT<T>(this->Append(other.Length()), other.Begin(), other.Length());
 
		this->Assign(other);
 
	}
 

	
 
	/**
 
	 * Assignment.
 
	 * @param other The new vector that.
 
	 * @param other The other vector to assign.
 
	 */
 
	SmallVector &operator=(const SmallVector &other)
 
	{
 
		this->Assign(other);
 
		return *this;
 
	}
 

	
 
	/**
 
	 * Generic assignment.
 
	 * @param other The other vector to assign.
 
	 */
 
	template <uint X>
 
	SmallVector &operator=(const SmallVector<T, X> &other)
 
	{
 
		this->Reset();
 
		MemCpyT<T>(this->Append(other.Length()), other.Begin(), other.Length());
 
		this->Assign(other);
 
		return *this;
 
	}
 

	
 
@@ -63,6 +81,18 @@ public:
 
	}
 

	
 
	/**
 
	 * Assign items from other vector.
 
	 */
 
	template <uint X>
 
	inline void Assign(const SmallVector<T, X> &other)
 
	{
 
		if ((const void *)&other == (void *)this) return;
 

	
 
		this->Clear();
 
		if (other.Length() > 0) MemCpyT<T>(this->Append(other.Length()), other.Begin(), other.Length());
 
	}
 

	
 
	/**
 
	 * Remove all items from the list.
 
	 */
 
	inline void Clear()
0 comments (0 inline, 0 general)