const size_type block_size = 0);
/**
- * Copy-Constructor. Dimension set to that of V, all components are copied
- * from V
+ * Copy Constructor. Dimension set to that of @p v, all components are
+ * copied from @p v.
*/
BlockVector (const BlockVector<Number> &V);
+#ifdef DEAL_II_WITH_CXX11
+ /**
+ * Move constructor. Creates a new vector by stealing the internal data
+ * of the vector @p v.
+ *
+ * @note This constructor is only available if deal.II is configured with
+ * C++11 support.
+ */
+ BlockVector (BlockVector<Number> &&v);
+#endif
+
+
#ifndef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG
/**
* Copy constructor taking a BlockVector of another data type. This will
* Copy operator: fill all components of the vector with the given scalar
* value.
*/
- BlockVector &operator = (const value_type s);
+ BlockVector &operator= (const value_type s);
/**
* Copy operator for arguments of the same type. Resize the present vector
* if necessary.
*/
- BlockVector &
- operator= (const BlockVector &V);
+ BlockVector<Number> &
+ operator= (const BlockVector<Number> &v);
+
+#ifdef DEAL_II_WITH_CXX11
+ /**
+ * Move the given vector. This operator replaces the present vector with
+ * @p v by efficiently swapping the internal data structures. @p v is
+ * left empty.
+ *
+ * @note This operator is only available if deal.II is configured with
+ * C++11 support.
+ */
+ BlockVector<Number> &operator= (BlockVector<Number> &&v);
+#endif
/**
* Copy operator for template arguments of different types. Resize the
* present vector if necessary.
*/
template <class Number2>
- BlockVector &
+ BlockVector<Number> &
operator= (const BlockVector<Number2> &V);
/**
* Copy a regular vector into a block vector.
*/
- BlockVector &
+ BlockVector<Number> &
operator= (const Vector<Number> &V);
#ifdef DEAL_II_WITH_TRILINOS
* A copy constructor from a Trilinos block vector to a deal.II block
* vector.
*/
- BlockVector &
+ BlockVector<Number> &
operator= (const TrilinosWrappers::BlockVector &V);
#endif
+
/**
* Reinitialize the BlockVector to contain <tt>n_blocks</tt> blocks of size
* <tt>block_size</tt> each.
template <typename Number>
inline
BlockVector<Number> &
-BlockVector<Number>::operator = (const value_type s)
+BlockVector<Number>::operator= (const value_type s)
{
AssertIsFinite(s);
- BaseClass::operator = (s);
+ BaseClass::operator= (s);
return *this;
}
template <typename Number>
inline
BlockVector<Number> &
-BlockVector<Number>::operator = (const BlockVector &v)
+BlockVector<Number>::operator= (const BlockVector<Number> &v)
{
reinit (v, true);
- BaseClass::operator = (v);
+ BaseClass::operator= (v);
return *this;
}
+#ifdef DEAL_II_WITH_CXX11
+template <typename Number>
+inline
+BlockVector<Number> &
+BlockVector<Number>::operator= (BlockVector<Number> &&v)
+{
+ swap(v);
+ // be nice and reset v to zero
+ v.reinit(0, 0, false);
+
+ return *this;
+}
+#endif
+
+
+
template <typename Number>
inline
BlockVector<Number> &
-BlockVector<Number>::operator = (const Vector<Number> &v)
+BlockVector<Number>::operator= (const Vector<Number> &v)
{
- BaseClass::operator = (v);
+ BaseClass::operator= (v);
return *this;
}
template <typename Number2>
inline
BlockVector<Number> &
-BlockVector<Number>::operator = (const BlockVector<Number2> &v)
+BlockVector<Number>::operator= (const BlockVector<Number2> &v)
{
reinit (v, true);
- BaseClass::operator = (v);
+ BaseClass::operator= (v);
return *this;
}
}
+#ifdef DEAL_II_WITH_CXX11
+template <typename Number>
+BlockVector<Number>::BlockVector (BlockVector<Number> &&v)
+ {
+ swap(v);
+ // be nice and reset v to zero
+ v.reinit(0, 0, false);
+ }
+#endif
+
+
#ifndef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG
template <typename Number>
template <typename Number>
inline
BlockVector<Number> &
-BlockVector<Number>::operator = (const TrilinosWrappers::BlockVector &v)
+BlockVector<Number>::operator= (const TrilinosWrappers::BlockVector &v)
{
- BaseClass::operator = (v);
+ BaseClass::operator= (v);
return *this;
}
#endif
Vector ();
/**
- * Copy-constructor. Sets the dimension to that of the given vector, and
+ * Copy constructor. Sets the dimension to that of the given vector, and
* copies all elements.
*
* We would like to make this constructor explicit, but standard containers
*/
Vector (const Vector<Number> &v);
+#ifdef DEAL_II_WITH_CXX11
+ /**
+ * Move constructor. Creates a new vector by stealing the internal data
+ * of the vector @p v.
+ *
+ * @note This constructor is only available if deal.II is configured with
+ * C++11 support.
+ */
+ Vector (Vector<Number> &&v);
+#endif
+
#ifndef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG
/**
*
* @dealiiOperationIsMultithreaded
*/
- Vector<Number> &operator = (const Number s);
+ Vector<Number> &operator= (const Number s);
/**
* Copy the given vector. Resize the present vector if necessary.
*/
Vector<Number> &operator= (const Vector<Number> &v);
+#ifdef DEAL_II_WITH_CXX11
+ /**
+ * Move the given vector. This operator replaces the present vector with
+ * @p v by efficiently swapping the internal data structures. @p v is
+ * left empty.
+ *
+ * @note This operator is only available if deal.II is configured with
+ * C++11 support.
+ */
+ Vector<Number> &operator= (Vector<Number> &&v);
+#endif
+
/**
* Copy the given vector. Resize the present vector if necessary.
*
* during configuration time.
*/
Vector<Number> &
- operator = (const PETScWrappers::Vector &v);
+ operator= (const PETScWrappers::Vector &v);
/**
* Another copy operator: copy the values from a parallel PETSc wrapper
* the other jobs do something else.
*/
Vector<Number> &
- operator = (const PETScWrappers::MPI::Vector &v);
+ operator= (const PETScWrappers::MPI::Vector &v);
#endif
* the other jobs do something else.
*/
Vector<Number> &
- operator = (const TrilinosWrappers::MPI::Vector &v);
+ operator= (const TrilinosWrappers::MPI::Vector &v);
/**
* Another copy operator: copy the values from a sequential Trilinos wrapper
* during configuration time.
*/
Vector<Number> &
- operator = (const TrilinosWrappers::Vector &v);
+ operator= (const TrilinosWrappers::Vector &v);
#endif
/**
* of different sizes makes not much sense anyway.
*/
template <typename Number2>
- bool operator == (const Vector<Number2> &v) const;
+ bool operator== (const Vector<Number2> &v) const;
/**
* Test for inequality. This function assumes that the present vector and
template <typename Number>
inline
Vector<Number> &
-Vector<Number>::operator = (const Vector<Number> &v)
+Vector<Number>::operator= (const Vector<Number> &v)
{
dealii::internal::Vector::copy_vector (v, *this);
return *this;
+#ifdef DEAL_II_WITH_CXX11
+template <typename Number>
+inline
+Vector<Number> &
+Vector<Number>::operator= (Vector<Number> &&v)
+{
+ swap(v);
+ // be nice and reset v to zero
+ v.reinit(0, false);
+
+ return *this;
+}
+#endif
+
+
+
template <typename Number>
template <typename Number2>
inline
Vector<Number> &
-Vector<Number>::operator = (const Vector<Number2> &v)
+Vector<Number>::operator= (const Vector<Number2> &v)
{
internal::Vector::copy_vector (v, *this);
return *this;
Vector<Number>::save (Archive &ar, const unsigned int) const
{
// forward to serialization function in the base class.
- ar &static_cast<const Subscriptor &>(*this);
+ ar &static_cast<const Subscriptor &>(*this);
ar &vec_size &max_vec_size ;
ar &boost::serialization::make_array(val, max_vec_size);
-
template <typename Number>
Vector<Number>::Vector (const Vector<Number> &v)
:
}
-#ifndef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG
+#ifdef DEAL_II_WITH_CXX11
+template <typename Number>
+Vector<Number>::Vector (Vector<Number> &&v)
+{
+ swap(v);
+ // be nice and reset v to zero
+ v.reinit(0, false);
+}
+#endif
+
+
+
+#ifndef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG
template <typename Number>
template <typename OtherNumber>
Vector<Number>::Vector (const Vector<OtherNumber> &v)
std::copy (v.begin(), v.end(), begin());
}
}
-
#endif
-#ifdef DEAL_II_WITH_PETSC
+#ifdef DEAL_II_WITH_PETSC
template <typename Number>
Vector<Number>::Vector (const PETScWrappers::Vector &v)
#endif
+
#ifdef DEAL_II_WITH_TRILINOS
template <typename Number>
#endif
+
template <typename Number>
template <typename Number2>
void Vector<Number>::reinit (const Vector<Number2> &v,
reinit (v.size(), fast);
}
-// Moved to vector.h as an inline function by Luca Heltai on
-// 2009/04/12 to prevent strange compiling errors, after making swap
-// virtual.
-// template <typename Number>
-// void
-// Vector<Number>::swap (Vector<Number> &v)
-// {
-// std::swap (vec_size, v.vec_size);
-// std::swap (max_vec_size, v.max_vec_size);
-// std::swap (val, v.val);
-// }
-
template <typename Number>
template <typename Number>
Vector<Number> &
-Vector<Number>::operator = (const Number s)
+Vector<Number>::operator= (const Number s)
{
AssertIsFinite(s);
if (s != Number())
#ifdef DEAL_II_BOOST_BIND_COMPILER_BUG
template <>
Vector<std::complex<float> > &
-Vector<std::complex<float> >::operator = (const std::complex<float> s)
+Vector<std::complex<float> >::operator= (const std::complex<float> s)
{
AssertIsFinite(s);
if (s != std::complex<float>())
template <typename Number>
Vector<Number> &
-Vector<Number>::operator = (const BlockVector<Number> &v)
+Vector<Number>::operator= (const BlockVector<Number> &v)
{
if (v.size() != vec_size)
reinit (v.size(), true);
template <typename Number>
Vector<Number> &
-Vector<Number>::operator = (const PETScWrappers::Vector &v)
+Vector<Number>::operator= (const PETScWrappers::Vector &v)
{
if (v.size() != vec_size)
reinit (v.size(), true);
template <typename Number>
Vector<Number> &
-Vector<Number>::operator = (const PETScWrappers::MPI::Vector &v)
+Vector<Number>::operator= (const PETScWrappers::MPI::Vector &v)
{
// do this in a two-stage process:
// first convert to a sequential petsc
template <typename Number>
Vector<Number> &
-Vector<Number>::operator = (const TrilinosWrappers::MPI::Vector &v)
+Vector<Number>::operator= (const TrilinosWrappers::MPI::Vector &v)
{
// Generate a localized version
// of the Trilinos vectors and
template <typename Number>
Vector<Number> &
-Vector<Number>::operator = (const TrilinosWrappers::Vector &v)
+Vector<Number>::operator= (const TrilinosWrappers::Vector &v)
{
if (v.size() != vec_size)
reinit (v.size(), true);
template <typename Number>
template <typename Number2>
bool
-Vector<Number>::operator == (const Vector<Number2> &v) const
+Vector<Number>::operator== (const Vector<Number2> &v) const
{
Assert (vec_size!=0, ExcEmptyObject());
Assert (vec_size == v.size(), ExcDimensionMismatch(vec_size, v.size()));