]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Checkpoint, wrote aligned vector move ctor
authordanshapero <shapero.daniel@gmail.com>
Fri, 22 Apr 2016 05:48:39 +0000 (22:48 -0700)
committerdanshapero <shapero.daniel@gmail.com>
Wed, 18 May 2016 00:44:45 +0000 (17:44 -0700)
include/deal.II/base/aligned_vector.h

index 5f9d441dfb02be98d1e7151e4c940ac1f7288155..7040bace72d0b7763754b843001156dfc945ef1c 100644 (file)
@@ -91,6 +91,16 @@ public:
    */
   AlignedVector (const AlignedVector<T> &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<T> &&vec);
+#endif
+
   /**
    * Assignment to the input vector @p vec.
    *
@@ -99,6 +109,16 @@ public:
   AlignedVector &
   operator = (const AlignedVector<T> &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<T> &&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<T>::AlignedVector (const AlignedVector<T> &vec)
 
 
 
+#ifdef DEAL_II_WITH_CXX11
+template < class T >
+inline
+AlignedVector<T>::AlignedVector (AlignedVector<T> &&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<T> &
@@ -515,6 +552,28 @@ AlignedVector<T>::operator = (const AlignedVector<T> &vec)
 
 
 
+#ifdef DEAL_II_WITH_CXX11
+template < class T >
+inline
+AlignedVector<T> &
+AlignedVector<T>::operator = (AlignedVector<T> &&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

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.