1
0
Fork 0

(svn r24448) -Fix [FS#5255]: Copy constructor and assignment operator cannot be implicit template specialisations. (adf88)

release/1.3
frosch 2012-07-29 20:02:25 +00:00
parent 9f6ab0541e
commit f9819c6645
1 changed files with 34 additions and 4 deletions

View File

@ -39,21 +39,39 @@ public:
* Copy constructor. * Copy constructor.
* @param other The other vector to copy. * @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> template <uint X>
SmallVector(const SmallVector<T, X> &other) : data(NULL), items(0), capacity(0) 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. * 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> template <uint X>
SmallVector &operator=(const SmallVector<T, X> &other) SmallVector &operator=(const SmallVector<T, X> &other)
{ {
this->Reset(); this->Assign(other);
MemCpyT<T>(this->Append(other.Length()), other.Begin(), other.Length());
return *this; return *this;
} }
@ -62,6 +80,18 @@ public:
free(this->data); free(this->data);
} }
/**
* 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. * Remove all items from the list.
*/ */