changed QSE_CPP_ENABLE_CPP1_MOVE to QSE_CPP_ENABLE_CPP11_MOVE
This commit is contained in:
parent
e53cb861a7
commit
4db106fcc3
@ -36,9 +36,9 @@
|
|||||||
|
|
||||||
#if (__cplusplus >= 201103L) // C++11
|
#if (__cplusplus >= 201103L) // C++11
|
||||||
|
|
||||||
/// The QSE_CPP_ENABLE_CPP1_MOVE macro enables C++11 move semantics
|
/// The QSE_CPP_ENABLE_CPP11_MOVE macro enables C++11 move semantics
|
||||||
/// in various classes.
|
/// in various classes.
|
||||||
#define QSE_CPP_ENABLE_CPP1_MOVE 1
|
#define QSE_CPP_ENABLE_CPP11_MOVE 1
|
||||||
|
|
||||||
// The QSE_CPP_CALL_DESTRUCTOR() macro calls a destructor explicitly.
|
// The QSE_CPP_CALL_DESTRUCTOR() macro calls a destructor explicitly.
|
||||||
#define QSE_CPP_CALL_DESTRUCTOR(ptr, class_name) ((ptr)->~class_name())
|
#define QSE_CPP_CALL_DESTRUCTOR(ptr, class_name) ((ptr)->~class_name())
|
||||||
@ -114,7 +114,7 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
|
|
||||||
template<typename T> struct QSE_CPP_RMREF { typedef T Type; };
|
template<typename T> struct QSE_CPP_RMREF { typedef T Type; };
|
||||||
template<typename T> struct QSE_CPP_RMREF<T&> { typedef T Type; };
|
template<typename T> struct QSE_CPP_RMREF<T&> { typedef T Type; };
|
||||||
|
@ -128,7 +128,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
|
|
||||||
Array (SelfType&& array):
|
Array (SelfType&& array):
|
||||||
Mmged(array.getMmgr()),
|
Mmged(array.getMmgr()),
|
||||||
@ -168,7 +168,7 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
SelfType& operator= (SelfType&& array)
|
SelfType& operator= (SelfType&& array)
|
||||||
{
|
{
|
||||||
if (this != &array)
|
if (this != &array)
|
||||||
@ -236,7 +236,7 @@ protected:
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
T* clone_buffer_by_moving (T* srcbuf, qse_size_t capa, qse_size_t cnt)
|
T* clone_buffer_by_moving (T* srcbuf, qse_size_t capa, qse_size_t cnt)
|
||||||
{
|
{
|
||||||
QSE_ASSERT (capa > 0);
|
QSE_ASSERT (capa > 0);
|
||||||
@ -306,7 +306,7 @@ protected:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
void put_item_by_moving (qse_size_t index, T&& value)
|
void put_item_by_moving (qse_size_t index, T&& value)
|
||||||
{
|
{
|
||||||
if (index >= this->count)
|
if (index >= this->count)
|
||||||
@ -432,7 +432,7 @@ public:
|
|||||||
this->update (index, value);
|
this->update (index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
void setValueAt (qse_size_t index, T&& value)
|
void setValueAt (qse_size_t index, T&& value)
|
||||||
{
|
{
|
||||||
this->update (index, QSE_CPP_RVREF(value));
|
this->update (index, QSE_CPP_RVREF(value));
|
||||||
@ -466,7 +466,7 @@ protected:
|
|||||||
// shift the existing elements to the back by one slot.
|
// shift the existing elements to the back by one slot.
|
||||||
for (qse_size_t i = this->count; i > index; i--)
|
for (qse_size_t i = this->count; i > index; i--)
|
||||||
{
|
{
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
this->put_item_by_moving (i, QSE_CPP_RVREF(this->buffer[i - 1]));
|
this->put_item_by_moving (i, QSE_CPP_RVREF(this->buffer[i - 1]));
|
||||||
#else
|
#else
|
||||||
this->put_item (i, this->buffer[i - 1]);
|
this->put_item (i, this->buffer[i - 1]);
|
||||||
@ -503,7 +503,7 @@ public:
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
qse_size_t insert (qse_size_t index, T&& value)
|
qse_size_t insert (qse_size_t index, T&& value)
|
||||||
{
|
{
|
||||||
// Unlike insert() in RedBlackTree and HashList,
|
// Unlike insert() in RedBlackTree and HashList,
|
||||||
@ -530,7 +530,7 @@ public:
|
|||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
qse_size_t update (qse_size_t index, T&& value)
|
qse_size_t update (qse_size_t index, T&& value)
|
||||||
{
|
{
|
||||||
QSE_ASSERT (index < this->count);
|
QSE_ASSERT (index < this->count);
|
||||||
@ -548,7 +548,7 @@ public:
|
|||||||
return this->insert (index, value);
|
return this->insert (index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
qse_size_t upsert (qse_size_t index, T&& value)
|
qse_size_t upsert (qse_size_t index, T&& value)
|
||||||
{
|
{
|
||||||
if (index < this->count)
|
if (index < this->count)
|
||||||
@ -566,7 +566,7 @@ public:
|
|||||||
return this->insert (index, value);
|
return this->insert (index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
qse_size_t ensert (qse_size_t index, T&& value)
|
qse_size_t ensert (qse_size_t index, T&& value)
|
||||||
{
|
{
|
||||||
if (index < this->count)
|
if (index < this->count)
|
||||||
@ -700,7 +700,7 @@ public:
|
|||||||
qse_size_t cnt = this->count;
|
qse_size_t cnt = this->count;
|
||||||
if (cnt > capa) cnt = capa;
|
if (cnt > capa) cnt = capa;
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
T* tmp = this->clone_buffer_by_moving (this->buffer, capa, cnt);
|
T* tmp = this->clone_buffer_by_moving (this->buffer, capa, cnt);
|
||||||
#else
|
#else
|
||||||
T* tmp = this->clone_buffer (this->buffer, capa, cnt);
|
T* tmp = this->clone_buffer (this->buffer, capa, cnt);
|
||||||
|
@ -135,7 +135,7 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
BinaryHeap (SelfType& heap): ParentType (heap)
|
BinaryHeap (SelfType& heap): ParentType (heap)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
SelfType& operator= (SelfType&& heap)
|
SelfType& operator= (SelfType&& heap)
|
||||||
{
|
{
|
||||||
if (this != &heap)
|
if (this != &heap)
|
||||||
@ -212,7 +212,7 @@ public:
|
|||||||
return this->sift_up(index);
|
return this->sift_up(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
qse_size_t insert (T&& value)
|
qse_size_t insert (T&& value)
|
||||||
{
|
{
|
||||||
qse_size_t index = this->count;
|
qse_size_t index = this->count;
|
||||||
@ -234,7 +234,7 @@ public:
|
|||||||
return (this->greater_than(value, old))? this->sift_up(index): this->sift_down(index);
|
return (this->greater_than(value, old))? this->sift_up(index): this->sift_down(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
qse_size_t update (qse_size_t index, T&& value)
|
qse_size_t update (qse_size_t index, T&& value)
|
||||||
{
|
{
|
||||||
T old = QSE_CPP_RVREF(this->buffer[index]);
|
T old = QSE_CPP_RVREF(this->buffer[index]);
|
||||||
|
@ -20,7 +20,7 @@ printf ("copy constructor %d\n", *q.x);
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
Julia (Julia&& q)
|
Julia (Julia&& q)
|
||||||
{
|
{
|
||||||
printf ("move constructor %d\n", *q.x);
|
printf ("move constructor %d\n", *q.x);
|
||||||
@ -51,7 +51,7 @@ printf ("operator= %d\n", *q.x);
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
Julia& operator= (Julia&& q)
|
Julia& operator= (Julia&& q)
|
||||||
{
|
{
|
||||||
if (this != &q)
|
if (this != &q)
|
||||||
@ -86,7 +86,7 @@ int main ()
|
|||||||
a0.remove (2, 5);
|
a0.remove (2, 5);
|
||||||
|
|
||||||
a0.update (5, Julia(9999));
|
a0.update (5, Julia(9999));
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
JuliaArray a1 ((JuliaArray&&)a0);
|
JuliaArray a1 ((JuliaArray&&)a0);
|
||||||
#else
|
#else
|
||||||
JuliaArray a1 (a0);
|
JuliaArray a1 (a0);
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
this->x = new int (*q.x);
|
this->x = new int (*q.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
Julia (Julia&& q)
|
Julia (Julia&& q)
|
||||||
{
|
{
|
||||||
this->x = q.x;
|
this->x = q.x;
|
||||||
@ -46,7 +46,7 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(QSE_CPP_ENABLE_CPP1_MOVE)
|
#if defined(QSE_CPP_ENABLE_CPP11_MOVE)
|
||||||
Julia& operator= (Julia&& q)
|
Julia& operator= (Julia&& q)
|
||||||
{
|
{
|
||||||
if (this != &q)
|
if (this != &q)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user