From 4d7819d8a93bdefa24c0685d25ab42a687ca10cc Mon Sep 17 00:00:00 2001 From: jhoffert Date: Thu, 10 Jan 2008 15:55:52 +0000 Subject: Fixed error leaks with bracket operator on iterators --- TAO/tao/Unbounded_Basic_String_Sequence_T.h | 53 +++++++++++++++++------------ 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/TAO/tao/Unbounded_Basic_String_Sequence_T.h b/TAO/tao/Unbounded_Basic_String_Sequence_T.h index fa187be0c38..20b6b3d30d8 100644 --- a/TAO/tao/Unbounded_Basic_String_Sequence_T.h +++ b/TAO/tao/Unbounded_Basic_String_Sequence_T.h @@ -306,15 +306,6 @@ public: this->sequence_->release ()); } - /// @copydoc details::generic_sequence::operator[] - //inline const_element_type operator[](CORBA::ULong i) const { - // return const_element_type (impl_[i], release()); - //} - /// @copydoc details::generic_sequence::operator[] - //inline element_type operator[](CORBA::ULong i) { - // return element_type(impl_[i], release()); - //} - /// Returns a const reference to the item contained at the current position //const value_type & operator* (void) const const_element_type operator* (void) const @@ -408,12 +399,20 @@ public: return this->pos_ - rhs.pos_; } + /// Element operator/assignment + element_type operator[] (difference_type n) + { + // Return the element at position pos_ + n + return element_type ((*(this->sequence_))[this->pos_ + n], + this->sequence_->release ()); + } /// Element operator/assignment - value_type & operator[] (difference_type n) + const_element_type operator[] (difference_type n) const { - // Return the element at position n - return (*(this->sequence_))[this->pos_ + n]; + // Return the element at position pos_ + n + return const_element_type ((*(this->sequence_))[this->pos_ + n], + this->sequence_->release ()); } /// Less than @@ -632,11 +631,12 @@ public: return this->pos_ - rhs.pos_; } - /// Element operator/assignment - const value_type & operator[] (difference_type n) const + /// Element operator + const_element_type operator[] (difference_type n) const { - // Return the element at position n - return (*(this->sequence_))[this->pos_ + n]; + // Return the element at position pos_ + n + return const_element_type ((*(this->sequence_))[this->pos_ + n], + this->sequence_->release ()); } /// Less than @@ -850,12 +850,20 @@ public: return rhs.pos_ - this->pos_; } + /// Element operator/assignment + element_type operator[] (difference_type n) + { + // Return the element at position pos_ + n + return element_type ((*(this->sequence_))[this->pos_ + n], + this->sequence_->release ()); + } /// Element operator/assignment - value_type & operator[] (difference_type n) + const_element_type operator[] (difference_type n) const { - // Return the element at position n - return (*(this->sequence_))[this->pos_ - n]; + // Return the element at position pos_ + n + return const_element_type ((*(this->sequence_))[this->pos_ + n], + this->sequence_->release ()); } /// Less than @@ -1091,10 +1099,11 @@ public: } /// Element operator/assignment - const value_type & operator[] (difference_type n) const + const_element_type operator[] (difference_type n) const { - // Return the element at position n - return (*(this->sequence_))[this->pos_ - n]; + // Return the element at position pos_ + n + return const_element_type ((*(this->sequence_))[this->pos_ + n], + this->sequence_->release ()); } /// Less than -- cgit v1.2.1