rvalue functions for containers
This commit is contained in:
@@ -49,8 +49,8 @@ public:
|
||||
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
|
||||
resize(pid_size, f);
|
||||
}
|
||||
inline PIDeque(PIDeque<T> && other): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
|
||||
swap(other);
|
||||
inline PIDeque(PIDeque<T> && other): pid_data(other.pid_data), pid_size(other.pid_size), pid_rsize(other.pid_size), pid_start(other.pid_start) {
|
||||
other._reset();
|
||||
}
|
||||
inline virtual ~PIDeque() {
|
||||
//piCout << "~PIDeque";
|
||||
@@ -70,7 +70,8 @@ public:
|
||||
}
|
||||
|
||||
inline PIDeque<T> & operator =(PIDeque<T> && other) {
|
||||
swap(other);
|
||||
PIDeque<T> moved(std::move(other));
|
||||
swap(moved);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -323,12 +324,6 @@ public:
|
||||
piSwap<size_t>(pid_rsize, other.pid_rsize);
|
||||
piSwap<ssize_t>(pid_start, other.pid_start);
|
||||
}
|
||||
inline void swap(PIDeque<T> && other) {
|
||||
piSwap<T*>(pid_data, other.pid_data);
|
||||
piSwap<size_t>(pid_size, other.pid_size);
|
||||
piSwap<size_t>(pid_rsize, other.pid_rsize);
|
||||
piSwap<ssize_t>(pid_start, other.pid_start);
|
||||
}
|
||||
|
||||
typedef int (*CompareFunc)(const T * , const T * );
|
||||
static int compare_func(const T * t0, const T * t1) {return (*t0) < (*t1) ? -1 : ((*t0) == (*t1) ? 0 : 1);}
|
||||
@@ -387,7 +382,9 @@ public:
|
||||
inline PIDeque<T> & operator <<(const PIDeque<T> & t) {return append(t);}
|
||||
|
||||
inline PIDeque<T> & push_front(const T & v) {insert(0, v); return *this;}
|
||||
inline PIDeque<T> & push_front(T && v) {insert(0, std::move(v)); return *this;}
|
||||
inline PIDeque<T> & prepend(const T & v) {return push_front(v);}
|
||||
inline PIDeque<T> & prepend(T && v) {return push_front(std::move(v));}
|
||||
|
||||
inline PIDeque<T> & pop_back() {if (pid_size == 0) return *this; resize(pid_size - 1); return *this;}
|
||||
inline PIDeque<T> & pop_front() {if (pid_size == 0) return *this; remove(0); return *this;}
|
||||
@@ -525,7 +522,7 @@ private:
|
||||
template<> inline void PIDeque<T>::newT(T * dst, const T * src, size_t s) {PIINTROSPECTION_CONTAINER_USED(T, s); memcpy((void*)(dst), (const void*)(src), s * sizeof(T));} \
|
||||
template<> inline void PIDeque<T>::deleteT(T *, size_t sz) {PIINTROSPECTION_CONTAINER_UNUSED(T, sz);} \
|
||||
template<> inline void PIDeque<T>::elementNew(T * to, const T & from) {(*to) = from;} \
|
||||
template<> inline void PIDeque<T>::elementNew(T * to, T && from) {(*to) = from;} \
|
||||
template<> inline void PIDeque<T>::elementNew(T * to, T && from) {(*to) = std::move(from);} \
|
||||
template<> inline void PIDeque<T>::elementDelete(T &) {;} \
|
||||
template<> inline PIDeque<T> & PIDeque<T>::_resizeRaw(size_t new_size) { \
|
||||
if (new_size > pid_size) { \
|
||||
|
||||
Reference in New Issue
Block a user