fix bug in move constructor
This commit is contained in:
@@ -40,7 +40,7 @@ set(PIP_UTILS 1)
|
|||||||
if(LIBPROJECT)
|
if(LIBPROJECT)
|
||||||
set(PIP_UTILS ${UTILS})
|
set(PIP_UTILS ${UTILS})
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED 1)
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ template <typename T>
|
|||||||
class PIDeque {
|
class PIDeque {
|
||||||
public:
|
public:
|
||||||
inline PIDeque(): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
|
inline PIDeque(): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
|
||||||
//piCout << "PIDeque";
|
|
||||||
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
|
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
|
||||||
}
|
}
|
||||||
inline PIDeque(const PIDeque<T> & other): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
|
inline PIDeque(const PIDeque<T> & other): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
|
||||||
@@ -49,11 +48,10 @@ public:
|
|||||||
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
|
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
|
||||||
resize(pid_size, f);
|
resize(pid_size, f);
|
||||||
}
|
}
|
||||||
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) {
|
inline PIDeque(PIDeque<T> && other): pid_data(other.pid_data), pid_size(other.pid_size), pid_rsize(other.pid_rsize), pid_start(other.pid_start) {
|
||||||
other._reset();
|
other._reset();
|
||||||
}
|
}
|
||||||
inline virtual ~PIDeque() {
|
inline virtual ~PIDeque() {
|
||||||
//piCout << "~PIDeque";
|
|
||||||
PIINTROSPECTION_CONTAINER_DELETE(T)
|
PIINTROSPECTION_CONTAINER_DELETE(T)
|
||||||
PIINTROSPECTION_CONTAINER_FREE(T, (pid_rsize))
|
PIINTROSPECTION_CONTAINER_FREE(T, (pid_rsize))
|
||||||
deleteT(pid_data + pid_start, pid_size);
|
deleteT(pid_data + pid_start, pid_size);
|
||||||
@@ -70,8 +68,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline PIDeque<T> & operator =(PIDeque<T> && other) {
|
inline PIDeque<T> & operator =(PIDeque<T> && other) {
|
||||||
PIDeque<T> moved(std::move(other));
|
swap(other);
|
||||||
swap(moved);
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,8 +86,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
PIMap<Key, T> & operator =(PIMap<Key, T> && other) {
|
PIMap<Key, T> & operator =(PIMap<Key, T> && other) {
|
||||||
PIMap<Key, T> moved(std::move(other));
|
swap(other);
|
||||||
swap(moved);
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public:
|
|||||||
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
|
PIINTROSPECTION_CONTAINER_NEW(T, sizeof(T))
|
||||||
resize(piv_size, f);
|
resize(piv_size, f);
|
||||||
}
|
}
|
||||||
inline PIVector(PIVector<T> && other): piv_data(other.piv_data), piv_size(other.piv_size), piv_rsize(other.piv_size) {
|
inline PIVector(PIVector<T> && other): piv_data(other.piv_data), piv_size(other.piv_size), piv_rsize(other.piv_rsize) {
|
||||||
other._reset();
|
other._reset();
|
||||||
}
|
}
|
||||||
inline virtual ~PIVector() {
|
inline virtual ~PIVector() {
|
||||||
@@ -69,8 +69,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline PIVector<T> & operator =(PIVector<T> && other) {
|
inline PIVector<T> & operator =(PIVector<T> && other) {
|
||||||
PIVector<T> moved(std::move(other));
|
swap(other);
|
||||||
swap(moved);
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public:
|
|||||||
|
|
||||||
PIString & operator =(const PIString & o) {if (this == &o) return *this; clear(); *this += o; return *this;}
|
PIString & operator =(const PIString & o) {if (this == &o) return *this; clear(); *this += o; return *this;}
|
||||||
|
|
||||||
PIString & operator =(PIString && o) {PIString moved(std::move(o)); swap(moved); return *this;}
|
PIString & operator =(PIString && o) {swap(o); return *this;}
|
||||||
|
|
||||||
/*! \brief Return c-string representation of string
|
/*! \brief Return c-string representation of string
|
||||||
* \details Converts content of string to c-string and return
|
* \details Converts content of string to c-string and return
|
||||||
|
|||||||
31
main.cpp
31
main.cpp
@@ -31,23 +31,38 @@ int main() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
|
class db {
|
||||||
|
public:
|
||||||
|
db() {
|
||||||
|
for (int i=0; i<1000; ++i)
|
||||||
|
x << sin(double(i)/180.0);
|
||||||
|
printf("jkfkhg\n");
|
||||||
|
}
|
||||||
|
// db(const db & d) {x = d.x;}
|
||||||
|
// db(db && o) {x.swap(o.x);}
|
||||||
|
private:
|
||||||
|
PIVector<double> x;
|
||||||
|
};
|
||||||
|
|
||||||
#include "picodeparser.h"
|
#include "picodeparser.h"
|
||||||
int main() {
|
int main() {
|
||||||
piDebug = false;
|
piDebug = false;
|
||||||
PIString t("1234567890-=");
|
printf("==============\n");
|
||||||
double min = -1, max = -1, mean = 0;
|
double min = -1, max = -1, mean = 0;
|
||||||
for (int i = 0; i < 50; ++i) {
|
for (int i = 0; i < 50; ++i) {
|
||||||
PITimeMeasurer tm;
|
PITimeMeasurer tm;
|
||||||
/*PICodeParser cp;
|
/*PICodeParser cp;
|
||||||
cp.parseFile("SH_plugin_base.h");*/
|
cp.parseFile("SH_plugin_base.h");*/
|
||||||
PIStringList sl;
|
PIVector<db> sl;
|
||||||
sl.reserve(500000);
|
sl.reserve(10000);
|
||||||
for (int i = 0; i < 500000; ++i) {
|
db d;
|
||||||
// PIString s(t);
|
for (int i = 0; i < 10000; ++i) {
|
||||||
// sl << s;
|
// db b(d);
|
||||||
sl.push_back(PIString(t));
|
// db c(b);
|
||||||
//sl << PIString("1234567890-=");
|
// c = b;
|
||||||
|
// sl << c;
|
||||||
|
sl << db(d);
|
||||||
|
// sl << std::move(d);
|
||||||
}
|
}
|
||||||
double ms = tm.elapsed_m();
|
double ms = tm.elapsed_m();
|
||||||
if (min < 0) min = ms;
|
if (min < 0) min = ms;
|
||||||
|
|||||||
Reference in New Issue
Block a user