From a60bd3d2071a8e89a03c4a57db07955eeaa69669 Mon Sep 17 00:00:00 2001 From: danshapero Date: Thu, 21 Apr 2016 22:48:39 -0700 Subject: [PATCH] Checkpoint, wrote aligned vector move ctor --- include/deal.II/base/aligned_vector.h | 59 +++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/include/deal.II/base/aligned_vector.h b/include/deal.II/base/aligned_vector.h index 5f9d441dfb..7040bace72 100644 --- a/include/deal.II/base/aligned_vector.h +++ b/include/deal.II/base/aligned_vector.h @@ -91,6 +91,16 @@ public: */ AlignedVector (const AlignedVector &vec); +#ifdef DEAL_II_WITH_CXX11 + /** + * Move constructor. Create a new aligned vector by stealing the contents of + * @p vec. + * + * @note This constructor is only available if deal.II is built with C++11. + */ + AlignedVector (AlignedVector &&vec); +#endif + /** * Assignment to the input vector @p vec. * @@ -99,6 +109,16 @@ public: AlignedVector & operator = (const AlignedVector &vec); +#ifdef DEAL_II_WITH_CXX11 + /** + * Move assignment operator. + * + * @note This operator is only available if deal.II is built with C++11. + */ + AlignedVector & + operator = (AlignedVector &&vec); +#endif + /** * Change the size of the vector. It keeps old elements previously available * but does not initialize the newly allocated memory, leaving it in an @@ -502,6 +522,23 @@ AlignedVector::AlignedVector (const AlignedVector &vec) +#ifdef DEAL_II_WITH_CXX11 +template < class T > +inline +AlignedVector::AlignedVector (AlignedVector &&vec) + : + _data (vec._data), + _end_data (vec._end_data), + _end_allocated (vec._end_allocated) +{ + vec._data = nullptr; + vec._end_data = nullptr; + vec._end_allocated = nullptr; +} +#endif + + + template < class T > inline AlignedVector & @@ -515,6 +552,28 @@ AlignedVector::operator = (const AlignedVector &vec) +#ifdef DEAL_II_WITH_CXX11 +template < class T > +inline +AlignedVector & +AlignedVector::operator = (AlignedVector &&vec) +{ + clear(); + + _data = vec._data; + _end_data = vec._end_data; + _end_allocated = vec._end_allocated; + + vec._data = nullptr; + vec._end_data = nullptr; + vec._end_allocated = nullptr; + + return *this; +} +#endif + + + template < class T > inline void -- 2.39.5