From: Wolfgang Bangerth Date: Wed, 19 Jul 2017 16:53:46 +0000 (-0600) Subject: Mark copy operators as explicitly deleted. X-Git-Tag: v9.0.0-rc1~1402^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4631%2Fhead;p=dealii.git Mark copy operators as explicitly deleted. The operator=() of all accessor classes had previously been hidden by making them private and not implementing them. C++11 now allows us to bring them out of the dark and into the light by making them public, but marking them as '=delete'. --- diff --git a/include/deal.II/dofs/dof_accessor.h b/include/deal.II/dofs/dof_accessor.h index 5bc31e1e14..b7944069fe 100644 --- a/include/deal.II/dofs/dof_accessor.h +++ b/include/deal.II/dofs/dof_accessor.h @@ -287,6 +287,18 @@ public: */ template DoFAccessor(const DoFAccessor &); + + /** + * 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 DoF handler objects. + * Consequently, this operator is declared as deleted and can not be used. + */ + DoFAccessor & + operator = (const DoFAccessor &da) = delete; + /** * @} */ @@ -670,18 +682,6 @@ protected: template friend class DoFAccessor; private: - /** - * Copy operator. This is normally 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. We declare - * this function here private, thus it may not be used from outside. - * Furthermore it is not implemented and will give a linker error if used - * anyway. - */ - DoFAccessor & - operator = (const DoFAccessor &da); /** * Make the DoFHandler class a friend so that it can call the set_xxx() @@ -801,6 +801,17 @@ public: template DoFAccessor (const DoFAccessor &); + /** + * 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 DoF handler objects. + * Consequently, this operator is declared as deleted and can not be used. + */ + DoFAccessor<0,DoFHandlerType<1,spacedim>, level_dof_access> & + operator = (const DoFAccessor<0,DoFHandlerType<1,spacedim>, level_dof_access> &da) = delete; + /** * @} */ @@ -811,12 +822,6 @@ public: const DoFHandlerType<1,spacedim> & get_dof_handler () const; - /** - * Copy operator. - */ - DoFAccessor<0,DoFHandlerType<1,spacedim>, level_dof_access> & - operator = (const DoFAccessor<0,DoFHandlerType<1,spacedim>, level_dof_access> &da); - /** * Implement the copy operator needed for the iterator classes. */ @@ -1228,6 +1233,17 @@ public: explicit DoFCellAccessor (const DoFAccessor &); + /** + * 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 DoF handler objects. + * Consequently, this operator is declared as deleted and can not be used. + */ + DoFCellAccessor & + operator = (const DoFCellAccessor &da) = delete; + /** * @} */ @@ -1716,18 +1732,6 @@ public: void update_cell_dof_indices_cache () const; private: - /** - * Copy operator. This is normally 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. We declare - * this function here private, thus it may not be used from outside. - * Furthermore it is not implemented and will give a linker error if used - * anyway. - */ - DoFCellAccessor & - operator = (const DoFCellAccessor &da); /** * Make the DoFHandler class a friend so that it can call the diff --git a/include/deal.II/grid/tria_accessor.h b/include/deal.II/grid/tria_accessor.h index 0138bbb35d..01fe5af177 100644 --- a/include/deal.II/grid/tria_accessor.h +++ b/include/deal.II/grid/tria_accessor.h @@ -293,6 +293,16 @@ 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. @@ -316,16 +326,6 @@ protected: bool operator < (const TriaAccessorBase &other) const; protected: - /** - * Copy operator. This is normally used in a context like iterator a,b; - * *a=*b;. Since the meaning is to copy the object pointed to by @p b - * to the object pointed to by @p a and since accessors are not real but - * virtual objects, this operation is not useful for iterators on - * triangulations. We declare this function here private, thus it may not be - * used from outside. Furthermore it is not implemented and will give a - * linker error if used anyway. - */ - void operator = (const TriaAccessorBase *); /** * Compare for equality. @@ -623,6 +623,16 @@ public: template TriaAccessor (const TriaAccessor &); + /** + * 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 TriaAccessor &) = delete; + /** * Test for the element being used or not. The return value is @p true for * all iterators that are either normal iterators or active iterators, only @@ -1517,17 +1527,6 @@ private: void clear_children () const; private: - /** - * Copy operator. This is normally 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. We declare - * this function here private, thus it may not be used from outside. - * Furthermore it is not implemented and will give a linker error if used - * anyway. - */ - void operator = (const TriaAccessor &); template friend class Triangulation; @@ -2416,6 +2415,16 @@ public: template CellAccessor (const TriaAccessor &); + /** + * 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 CellAccessor &) = delete; + /** * @} */ @@ -3231,16 +3240,6 @@ private: * @ref GlossDirectionFlag. */ void set_direction_flag (const bool new_direction_flag) const; - /** - * Copy operator. This is normally used in a context like iterator a,b; - * *a=*b;. Since the meaning is to copy the object pointed to by @p b - * to the object pointed to by @p a and since accessors are not real but - * virtual objects, this operation is not useful for iterators on - * triangulations. We declare this function here private, thus it may not be - * used from outside. Furthermore it is not implemented and will give a - * linker error if used anyway. - */ - void operator = (const CellAccessor &); template friend class Triangulation;