]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added default move ctor/assignment to BlockVector, BlockVectorBase
authordanshapero <shapero.daniel@gmail.com>
Wed, 13 Apr 2016 05:29:55 +0000 (22:29 -0700)
committerdanshapero <shapero.daniel@gmail.com>
Wed, 13 Apr 2016 19:03:26 +0000 (12:03 -0700)
This makes a moved BlockVector have the right post-condition, i.e.
the state it would have after default construction.

include/deal.II/lac/block_vector.h
include/deal.II/lac/block_vector.templates.h
include/deal.II/lac/block_vector_base.h
tests/lac/block_vector_move_operations.with_cxx11=on.output

index 9f5aabdd17d197c8c5299bc02905ec8ad8914685..ac8a467d424dec4c8dd969078c01e77b07880e7d 100644 (file)
@@ -112,7 +112,7 @@ public:
    * @note This constructor is only available if deal.II is configured with
    * C++11 support.
    */
-  BlockVector (BlockVector<Number> &&v);
+  BlockVector (BlockVector<Number> &&v) = default;
 #endif
 
 
@@ -208,7 +208,7 @@ public:
    * @note This operator is only available if deal.II is configured with C++11
    * support.
    */
-  BlockVector<Number> &operator= (BlockVector<Number> &&v);
+  BlockVector<Number> &operator= (BlockVector<Number> &&v) = default;
 #endif
 
   /**
@@ -422,20 +422,6 @@ BlockVector<Number>::operator= (const BlockVector<Number> &v)
 
 
 
-#ifdef DEAL_II_WITH_CXX11
-template <typename Number>
-inline
-BlockVector<Number> &
-BlockVector<Number>::operator= (BlockVector<Number> &&v)
-{
-  swap(v);
-
-  return *this;
-}
-#endif
-
-
-
 template <typename Number>
 inline
 BlockVector<Number> &
index 0f1fcbe6f0cd8c60400cb271dce2238e060d9420..eb77a776a93d43c6c2fb8c538cc43acfa0d2a08c 100644 (file)
@@ -61,17 +61,6 @@ BlockVector<Number>::BlockVector (const BlockVector<Number> &v)
 }
 
 
-#ifdef DEAL_II_WITH_CXX11
-template <typename Number>
-BlockVector<Number>::BlockVector (BlockVector<Number> &&v)
-  :
-  BlockVectorBase<Vector<Number> > ()
-{
-  swap(v);
-}
-#endif
-
-
 #ifndef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG
 
 template <typename Number>
index 17d5eebaeb25e4281cbcab4711ef601f0058f020..fd7ddb6f747fca01494e74087112cb0dd3998cfe 100644 (file)
@@ -577,6 +577,23 @@ public:
    */
   BlockVectorBase ();
 
+#ifdef DEAL_II_WITH_CXX11
+  /**
+   * Copy constructor.
+   */
+  BlockVectorBase (const BlockVectorBase &V) = default;
+
+  /**
+   * Move constructor. Each block of the vector @p V is moved into the current
+   * object if the underlying <code>VectorType</code> is move-constructible,
+   * otherwise they are copied.
+   *
+   * @note This constructor is only available if deal.II is configured with
+   * C++11 support.
+   */
+  BlockVectorBase (BlockVectorBase &&V) = default;
+#endif
+
   /**
    * Update internal structures after resizing vectors. Whenever you reinited
    * a block of a block vector, the internal data structures are corrupted.
@@ -723,6 +740,14 @@ public:
   BlockVectorBase &
   operator= (const BlockVectorBase &V);
 
+#ifdef DEAL_II_WITH_CXX11
+  /**
+   * Move assignment operator. Move each block of the vector @p V into the
+   * current object if `VectorType` is move-constructible, otherwise copy them.
+   */
+  BlockVectorBase &operator= (BlockVectorBase &&V) = default;
+#endif
+
   /**
    * Copy operator for template arguments of different types.
    */
@@ -1468,6 +1493,7 @@ namespace internal
 } //namespace internal
 
 
+
 template <class VectorType>
 inline
 BlockVectorBase<VectorType>::BlockVectorBase ()
index bf0d55296d0e9a3682c5fa9e9f1ed3f8d45a06df..a86c63cf10b082bec7b25985a0caf2fbd3e9a38c 100644 (file)
@@ -30,7 +30,7 @@ DEAL::[block 1 ]  10.0000 11.0000
 DEAL::[block 2 ]  20.0000 21.0000 
 DEAL::[block 3 ]  30.0000 31.0000 
 DEAL::[block 4 ]  40.0000 41.0000 
-DEAL::old object size: 5
+DEAL::old object size: 0
 DEAL::Block vector: move assignemnt:
 DEAL::[block 0 ]  0.00000 1.00000 
 DEAL::[block 1 ]  10.0000 11.0000 

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.