Commit 446bd3c0 authored by Davis King's avatar Davis King

Gave array2d and matrix move constructors and move assignment operators.

parent 120f2a76
...@@ -160,6 +160,21 @@ namespace dlib ...@@ -160,6 +160,21 @@ namespace dlib
set_size(rows,cols); set_size(rows,cols);
} }
#ifdef DLIB_HAS_RVALUE_REFERENCES
array2d(array2d&& item)
{
swap(item);
}
array2d& operator= (
array2d&& rhs
)
{
swap(rhs);
return *this;
}
#endif
virtual ~array2d ( virtual ~array2d (
) { clear(); } ) { clear(); }
......
...@@ -122,6 +122,15 @@ namespace dlib ...@@ -122,6 +122,15 @@ namespace dlib
- std::bad_alloc - std::bad_alloc
!*/ !*/
array2d(
array2d&& item
);
/*!
ensures
- Moves the state of item into *this.
- #item is in a valid but unspecified state.
!*/
array2d ( array2d (
long rows, long rows,
long cols long cols
...@@ -218,6 +227,16 @@ namespace dlib ...@@ -218,6 +227,16 @@ namespace dlib
- swaps *this and item - swaps *this and item
!*/ !*/
array2d& operator= (
array2d&& rhs
);
/*!
ensures
- Moves the state of item into *this.
- #item is in a valid but unspecified state.
- returns #*this
!*/
long width_step ( long width_step (
) const; ) const;
/*! /*!
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "matrix_data_layout.h" #include "matrix_data_layout.h"
#include "matrix_assign_fwd.h" #include "matrix_assign_fwd.h"
#include "matrix_op.h" #include "matrix_op.h"
#include <utility>
#ifdef _MSC_VER #ifdef _MSC_VER
// Disable the following warnings for Visual Studio // Disable the following warnings for Visual Studio
...@@ -1106,6 +1107,21 @@ namespace dlib ...@@ -1106,6 +1107,21 @@ namespace dlib
matrix_assign(*this, m); matrix_assign(*this, m);
} }
#ifdef DLIB_HAS_RVALUE_REFERENCES
matrix(matrix&& item)
{
swap(item);
}
matrix& operator= (
matrix&& rhs
)
{
swap(rhs);
return *this;
}
#endif
template <typename U, size_t len> template <typename U, size_t len>
explicit matrix ( explicit matrix (
U (&array)[len] U (&array)[len]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment