From: Daniel Arndt Date: Wed, 16 Jan 2019 01:06:34 +0000 (+0100) Subject: modernize-use-equals-delete X-Git-Tag: v9.1.0-rc1~412^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=456c02ad25e7b66259603409d6d0ffbce065a360;p=dealii.git modernize-use-equals-delete --- diff --git a/contrib/utilities/run_clang_tidy.sh b/contrib/utilities/run_clang_tidy.sh index 2277ff4320..ace389e4d0 100755 --- a/contrib/utilities/run_clang_tidy.sh +++ b/contrib/utilities/run_clang_tidy.sh @@ -53,6 +53,7 @@ CHECKS="-*, modernize-redundant-void-arg, modernize-use-emplace, modernize-use-equals-default, + modernize-use-equals-delete, modernize-use-nullptr, modernize-use-using, mpi-*, diff --git a/include/deal.II/base/linear_index_iterator.h b/include/deal.II/base/linear_index_iterator.h index 363fb6f940..84b264da37 100644 --- a/include/deal.II/base/linear_index_iterator.h +++ b/include/deal.II/base/linear_index_iterator.h @@ -296,10 +296,10 @@ public: operator>(const DerivedIterator &) const; protected: - /** + /* * The inheriting class should have a default constructor. */ - LinearIndexIterator() = default; + LinearIndexIterator() = default; // NOLINT /** * Constructor that copies an accessor. diff --git a/include/deal.II/base/parameter_handler.h b/include/deal.II/base/parameter_handler.h index a57d3875fc..54527f6bee 100644 --- a/include/deal.II/base/parameter_handler.h +++ b/include/deal.II/base/parameter_handler.h @@ -843,18 +843,6 @@ class MultipleParameterLoop; */ class ParameterHandler : public Subscriptor { -private: - /** - * Inhibit automatic CopyConstructor. - */ - ParameterHandler(const ParameterHandler &) = delete; - - /** - * Inhibit automatic assignment operator. - */ - ParameterHandler & - operator=(const ParameterHandler &) = delete; - public: /** * List of possible output formats used for @@ -912,6 +900,17 @@ public: */ virtual ~ParameterHandler() override = default; + /** + * Inhibit automatic CopyConstructor. + */ + ParameterHandler(const ParameterHandler &) = delete; + + /** + * Inhibit automatic assignment operator. + */ + ParameterHandler & + operator=(const ParameterHandler &) = delete; + /** * Parse each line from a stream until the stream returns the eof * condition or error to provide values for known parameter fields. The second diff --git a/include/deal.II/base/symmetric_tensor.h b/include/deal.II/base/symmetric_tensor.h index 64e4105f82..f903c4078d 100644 --- a/include/deal.II/base/symmetric_tensor.h +++ b/include/deal.II/base/symmetric_tensor.h @@ -442,11 +442,6 @@ namespace internal */ Accessor(tensor_type &tensor, const TableIndices &previous_indices); - /** - * Default constructor. Not needed, so deleted. - */ - Accessor() = delete; - /** * Copy constructor. */ diff --git a/include/deal.II/base/table.h b/include/deal.II/base/table.h index 52094a8e8d..0c2ee33af4 100644 --- a/include/deal.II/base/table.h +++ b/include/deal.II/base/table.h @@ -178,11 +178,6 @@ namespace internal */ Accessor(const TableType &table, const iterator data); - /** - * Default constructor. Not needed, and invisible, so deleted. - */ - Accessor() = delete; - public: /** * Copy constructor. This constructor is public so that one can pass @@ -283,11 +278,6 @@ namespace internal */ Accessor(const TableType &table, const iterator data); - /** - * Default constructor. Not needed, so deleted. - */ - Accessor() = delete; - public: /** * Copy constructor. This constructor is public so that one can pass @@ -298,7 +288,6 @@ namespace internal */ Accessor(const Accessor &a); - /** * Index operator. Performs a range check. */ diff --git a/include/deal.II/fe/fe.h b/include/deal.II/fe/fe.h index 01b4b05546..0ab1093085 100644 --- a/include/deal.II/fe/fe.h +++ b/include/deal.II/fe/fe.h @@ -680,12 +680,6 @@ public: */ class InternalDataBase { - private: - /** - * Copy construction is forbidden. - */ - InternalDataBase(const InternalDataBase &) = delete; - public: /** * Constructor. Sets update_flags to @p update_default and @p first_cell @@ -698,6 +692,11 @@ public: */ virtual ~InternalDataBase() = default; + /** + * Copy construction is forbidden. + */ + InternalDataBase(const InternalDataBase &) = delete; + /** * A set of update flags specifying the kind of information that an * implementation of the FiniteElement interface needs to compute on each diff --git a/include/deal.II/fe/fe_values.h b/include/deal.II/fe/fe_values.h index 724506943b..671caca464 100644 --- a/include/deal.II/fe/fe_values.h +++ b/include/deal.II/fe/fe_values.h @@ -2046,11 +2046,18 @@ public: const FiniteElement &fe); /** - * The copy operator is deleted since objects of this class are not copyable. + * The copy assignment is deleted since objects of this class are not + * copyable. */ FEValuesBase & operator=(const FEValuesBase &) = delete; + /** + * The copy constructor is deleted since objects of this class are not + * copyable. + */ + FEValuesBase(const FEValuesBase &) = delete; + /** * Destructor. */ @@ -3391,12 +3398,6 @@ protected: const typename Triangulation::cell_iterator &cell); private: - /** - * Copy constructor. Since objects of this class are not copyable, we make - * it private, and also do not implement it. - */ - FEValuesBase(const FEValuesBase &); - /** * A cache for all possible FEValuesViews objects. */ diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index fba857e4d7..9698bb6038 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -310,6 +310,18 @@ public: */ static const unsigned int structure_dimension = structdim; + /** + * Copy operator. These operators are usually used in a context like + * iterator a,b; *a=*b;. Presumably, the intent here is to copy the + * object pointed to + * by @p b to the object pointed to by @p a. However, the result of + * dereferencing an iterator is not an object but an accessor; consequently, + * this operation is not useful for iterators on triangulations. + * Consequently, this operator is declared as deleted and can not be used. + */ + void + operator=(const TriaAccessorBase *) = delete; + protected: /** * Declare the data type that this accessor class expects to get passed from @@ -331,18 +343,6 @@ protected: */ TriaAccessorBase(const TriaAccessorBase &); - /** - * Copy operator. These operators are usually used in a context like - * iterator a,b; *a=*b;. Presumably, the intent here is to copy the - * object pointed to - * by @p b to the object pointed to by @p a. However, the result of - * dereferencing an iterator is not an object but an accessor; consequently, - * this operation is not useful for iterators on triangulations. - * Consequently, this operator is declared as deleted and can not be used. - */ - void - operator=(const TriaAccessorBase *) = delete; - /** * Copy operator. Since this is only called from iterators, do not return * anything, since the iterator will return itself. diff --git a/include/deal.II/lac/petsc_sparse_matrix.h b/include/deal.II/lac/petsc_sparse_matrix.h index a36670fbcb..e5f826ef0c 100644 --- a/include/deal.II/lac/petsc_sparse_matrix.h +++ b/include/deal.II/lac/petsc_sparse_matrix.h @@ -145,6 +145,17 @@ namespace PETScWrappers SparseMatrix & operator=(const double d); + /** + * The copy constructor is deleted. + */ + SparseMatrix(const SparseMatrix &) = delete; + + /** + * The copy assignment operator is deleted. + */ + SparseMatrix & + operator=(const SparseMatrix &) = delete; + /** * Throw away the present matrix and generate one that has the same * properties as if it were created by the constructor of this class with @@ -241,16 +252,6 @@ namespace PETScWrappers const MPI::Vector & V = MPI::Vector()) const; private: - /** - * Purposefully not implemented - */ - SparseMatrix(const SparseMatrix &) = delete; - /** - * Purposefully not implemented - */ - SparseMatrix & - operator=(const SparseMatrix &) = delete; - /** * Do the actual work for the respective reinit() function and the * matching constructor, i.e. create a matrix. Getting rid of the previous diff --git a/include/deal.II/lac/petsc_vector_base.h b/include/deal.II/lac/petsc_vector_base.h index 09ad999ca9..392cd2b198 100644 --- a/include/deal.II/lac/petsc_vector_base.h +++ b/include/deal.II/lac/petsc_vector_base.h @@ -269,6 +269,13 @@ namespace PETScWrappers */ explicit VectorBase(const Vec &v); + /** + * The copy assignment operator is deleted to avoid accidental usage with + * unexpected behavior. + */ + VectorBase & + operator=(const VectorBase &) = delete; + /** * Destructor */ @@ -806,15 +813,6 @@ namespace PETScWrappers const size_type * indices, const PetscScalar *values, const bool add_values); - - private: - /** - * Assignment operator. This is currently not implemented, so it is - * deliberately left as private (and undefined) to prevent accidental - * usage. - */ - VectorBase & - operator=(const VectorBase &) = delete; }; diff --git a/include/deal.II/lac/solver_gmres.h b/include/deal.II/lac/solver_gmres.h index 7c846bb58e..04f9fa48ae 100644 --- a/include/deal.II/lac/solver_gmres.h +++ b/include/deal.II/lac/solver_gmres.h @@ -238,6 +238,11 @@ public: */ SolverGMRES(SolverControl &cn, const AdditionalData &data = AdditionalData()); + /** + * The copy constructor is deleted. + */ + SolverGMRES(const SolverGMRES &) = delete; + /** * Solve the linear system $Ax=b$ for x. */ @@ -431,13 +436,6 @@ protected: * Auxiliary matrix for inverting @p H */ FullMatrix H1; - - -private: - /** - * No copy constructor. - */ - SolverGMRES(const SolverGMRES &); }; /** diff --git a/include/deal.II/numerics/time_dependent.h b/include/deal.II/numerics/time_dependent.h index 57e7ab631a..5a3b45c876 100644 --- a/include/deal.II/numerics/time_dependent.h +++ b/include/deal.II/numerics/time_dependent.h @@ -693,6 +693,19 @@ public: */ virtual ~TimeStepBase() override = default; + /** + * The copy constructor is deleted to avoid shallow copies with unexpected + * behavior. + */ + TimeStepBase(const TimeStepBase &) = delete; + + /** + * The copy assignment operator is dleetd to avoid shallow copies winth + * unexpected behavior. + */ + TimeStepBase & + operator=(const TimeStepBase &) = delete; + /** * Reconstruct all the data that is needed for this time level to work. This * function serves to reget all the variables and data structures to work @@ -926,24 +939,6 @@ private: void set_sweep_no(const unsigned int sweep_no); - - /** - * Copy constructor. I can see no reason why someone might want to use it, - * so I don't provide it. Since this class has pointer members, making it - * private prevents the compiler to provide it's own, incorrect one if - * anyone chose to copy such an object. - */ - TimeStepBase(const TimeStepBase &) = delete; - - /** - * Copy operator. I can see no reason why someone might want to use it, so I - * don't provide it. Since this class has pointer members, making it private - * prevents the compiler to provide it's own, incorrect one if anyone chose - * to copy such an object. - */ - TimeStepBase & - operator=(const TimeStepBase &) = delete; - // make the manager object a friend friend class TimeDependent; };