From d11a7e1a76d6d1d24e5f5b6c6fb0da5f770aff98 Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 3 Dec 2016 17:24:28 -0500 Subject: [PATCH] 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. --- include/deal.II/lac/la_parallel_block_vector.h | 5 ----- .../lac/la_parallel_block_vector.templates.h | 6 ------ include/deal.II/lac/la_vector.h | 11 ----------- include/deal.II/lac/vector_space_vector.h | 17 +++++++++++++++++ 4 files changed, 17 insertions(+), 22 deletions(-) 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 -- 2.39.5