From: wolf Date: Sat, 20 Feb 1999 13:40:10 +0000 (+0000) Subject: Add three conversion operators for iterators of different type. For example, it is... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b07e5d8a64800eb22d2d99b51a95236ab483aa9;p=dealii-svn.git Add three conversion operators for iterators of different type. For example, it is now perfectly legal to write Triangulation::cell_iterator cell = dof_handler.begin(); Previously, this was not possible, since the DoFHandler returned an object of type TriaIterator while the left hand side required a TriaIterator Since the first accessor is convertible into the second, it is now possible to convert the first data type into the second. git-svn-id: https://svn.dealii.org/trunk@856 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/grid/tria_iterator.h b/deal.II/deal.II/include/grid/tria_iterator.h index 0dc0afe7ae..ad5295d026 100644 --- a/deal.II/deal.II/include/grid/tria_iterator.h +++ b/deal.II/deal.II/include/grid/tria_iterator.h @@ -251,6 +251,30 @@ class TriaRawIterator : public bidirectional_iterator { const int index, const typename Accessor::AccessorData *local_data = 0); + /** + * This is a conversion operator + * (constructor) which takes another + * iterator type and copies the data; + * this conversion works, if there is + * a conversion path from the + * #OtherAccessor# class to the #Accessor# + * class of this object. One such path + * would be derived class to base class, + * which for example may be used to get + * a #Triangulation::raw_cell_iterator# from + * a #DoFHandler::raw_cell_iterator#, since + * the #DoFAccessor# class is derived from + * the #TriaAccessor# class. + * + * Since #TriaIterator# and + * #TriaActiveIterator# are derived classes + * of this class, this constructor also + * serves to convert these iterators with + * other accessor classes. + */ + template + TriaRawIterator (const TriaRawIterator &i); + /** * @name Dereferencing */ @@ -481,6 +505,29 @@ class TriaIterator : public TriaRawIterator { const int index, const typename Accessor::AccessorData *local_data = 0); + /** + * This is a conversion operator + * (constructor) which takes another + * iterator type and copies the data; + * this conversion works, if there is + * a conversion path from the + * #OtherAccessor# class to the #Accessor# + * class of this object. One such path + * would be derived class to base class, + * which for example may be used to get + * a #Triangulation::cell_iterator# from + * a #DoFHandler::cell_iterator#, since + * the #DoFAccessor# class is derived from + * the #TriaAccessor# class. + * + * Since #TriaActiveIterator# is a derived + * class of this class, this constructor + * also serves to convert these iterators + * with other accessor classes. + */ + template + TriaIterator (const TriaIterator &i); + /** * Assignment operator. */ @@ -612,6 +659,24 @@ class TriaActiveIterator : public TriaIterator { const int index, const typename Accessor::AccessorData *local_data = 0); + /** + * This is a conversion operator + * (constructor) which takes another + * iterator type and copies the data; + * this conversion works, if there is + * a conversion path from the + * #OtherAccessor# class to the #Accessor# + * class of this object. One such path + * would be derived class to base class, + * which for example may be used to get + * a #Triangulation::active_cell_iterator# from + * a #DoFHandler::active_cell_iterator#, since + * the #DoFAccessor# class is derived from + * the #TriaAccessor# class. + */ + template + TriaActiveIterator (const TriaActiveIterator &i); + /** * Assignment operator. */ @@ -694,6 +759,15 @@ class TriaActiveIterator : public TriaIterator { +template +template +inline +TriaRawIterator::TriaRawIterator (const TriaRawIterator &i) + : accessor (i.accessor) +{}; + + + template inline const Accessor & @@ -790,6 +864,26 @@ void TriaRawIterator::print (ostream &out) const { +template +template +inline +TriaIterator::TriaIterator (const TriaIterator &i) + : TriaRawIterator (static_cast >(i)) +{}; + + + +template +template +inline +TriaActiveIterator::TriaActiveIterator (const TriaActiveIterator &i) + : TriaIterator (static_cast >(i)) +{}; + + + + + template inline ostream & operator << (ostream &out, const TriaRawIterator &i) {