From: David Wells Date: Sat, 3 Dec 2016 22:24:28 +0000 (-0500) Subject: Make VectorSpaceVector's destructor virtual. X-Git-Tag: v8.5.0-rc1~345^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d11a7e1a76d6d1d24e5f5b6c6fb0da5f770aff98;p=dealii.git Make VectorSpaceVector's destructor virtual. Since the classes inheriting from VectorSpaceVector all implement their own memory management strategies, the destructor of the base class should always be virtual. --- diff --git a/include/deal.II/lac/la_parallel_block_vector.h b/include/deal.II/lac/la_parallel_block_vector.h index 2d325cf4ae..f96e64052e 100644 --- a/include/deal.II/lac/la_parallel_block_vector.h +++ b/include/deal.II/lac/la_parallel_block_vector.h @@ -167,11 +167,6 @@ namespace LinearAlgebra BlockVector (const std::vector &local_ranges, const MPI_Comm communicator); - /** - * Destructor. Clears memory. - */ - ~BlockVector (); - /** * Copy operator: fill all components of the vector with the given * scalar value. diff --git a/include/deal.II/lac/la_parallel_block_vector.templates.h b/include/deal.II/lac/la_parallel_block_vector.templates.h index d2d02ad1d7..1f5ea732de 100644 --- a/include/deal.II/lac/la_parallel_block_vector.templates.h +++ b/include/deal.II/lac/la_parallel_block_vector.templates.h @@ -146,12 +146,6 @@ namespace LinearAlgebra - template - BlockVector::~BlockVector () - {} - - - template BlockVector & BlockVector::operator = (const value_type s) diff --git a/include/deal.II/lac/la_vector.h b/include/deal.II/lac/la_vector.h index 144315e5c0..ea1c083abb 100644 --- a/include/deal.II/lac/la_vector.h +++ b/include/deal.II/lac/la_vector.h @@ -86,11 +86,6 @@ namespace LinearAlgebra template Vector(const InputIterator first, const InputIterator last); - /** - * Destructor, deallocates memory. - */ - virtual ~Vector(); - /** * Copies the data of the input vector @p in_vector. */ @@ -327,12 +322,6 @@ namespace LinearAlgebra - template - inline - Vector::~Vector() {} - - - template inline typename Vector::size_type Vector::size() const diff --git a/include/deal.II/lac/vector_space_vector.h b/include/deal.II/lac/vector_space_vector.h index cb8c95fdc8..b7158fa412 100644 --- a/include/deal.II/lac/vector_space_vector.h +++ b/include/deal.II/lac/vector_space_vector.h @@ -207,8 +207,25 @@ namespace LinearAlgebra * Return the memory consumption of this class in bytes. */ virtual std::size_t memory_consumption() const = 0; + + /** + * Destructor. Declared as virtual so that inheriting classes (which may + * manage their own memory) are destroyed correctly. + */ + virtual ~VectorSpaceVector(); }; /*@}*/ + + + +#ifndef DOXYGEN + // TODO we can get rid of this when we require C++11 by using '=default' + // above + template + inline + VectorSpaceVector::~VectorSpaceVector() + {} +#endif // DOXYGEN } DEAL_II_NAMESPACE_CLOSE