Thread: [Cppunit-cvs] cppunit2/include/cpptl _stlimpl.h, 1.1, 1.2 smallmap.h, 1.1, 1.2
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2006-09-05 21:41:33
|
Update of /cvsroot/cppunit/cppunit2/include/cpptl In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv3768/include/cpptl Modified Files: _stlimpl.h smallmap.h Log Message: - Fixed compilation issues reported by Comeau C++. Index: _stlimpl.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/_stlimpl.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** _stlimpl.h 5 Jun 2006 12:02:56 -0000 1.1 --- _stlimpl.h 5 Sep 2006 21:41:29 -0000 1.2 *************** *** 111,117 **** copy_with_construct_value( OutputIt firstDestIt, unsigned int count, const ValueType &value ) { ! while ( count-- >= 0 ) { ! new (*firstDestIt)( value ); ++firstDestIt; } --- 111,117 ---- copy_with_construct_value( OutputIt firstDestIt, unsigned int count, const ValueType &value ) { ! while ( count-- > 0 ) { ! construct( *firstDestIt, value ); ++firstDestIt; } Index: smallmap.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpptl/smallmap.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** smallmap.h 5 Jun 2006 12:02:56 -0000 1.1 --- smallmap.h 5 Sep 2006 21:41:30 -0000 1.2 *************** *** 121,125 **** { CPPTL_ASSERT_MESSAGE( map_ && map_->size_ && ! ( current_+n < map_->data_ + map_->size_ && current+n >= map_->data_), "SmallMapIterator::advance: advancing beyond end or beginning" ); current_ += n; --- 121,125 ---- { CPPTL_ASSERT_MESSAGE( map_ && map_->size_ && ! ( current_+n < map_->data_ + map_->size_ && current_+n >= map_->data_), "SmallMapIterator::advance: advancing beyond end or beginning" ); current_ += n; *************** *** 175,184 **** } ! SmallMapIterator( const SmallMapBase<Item> &map, Item *current ) : SuperClass( map, current ) { } ! SmallMapIterator( const SmallMapBase<Item> &map, size_t currentIndex ) : SuperClass( map, map.data_ + currentIndex ) { --- 175,184 ---- } ! SmallMapIterator( const SmallMapBase<T> &map, T *current ) : SuperClass( map, current ) { } ! SmallMapIterator( const SmallMapBase<T> &map, size_t currentIndex ) : SuperClass( map, map.data_ + currentIndex ) { *************** *** 187,191 **** SelfType &operator++() { ! increment(); return *this; } --- 187,191 ---- SelfType &operator++() { ! this->increment(); return *this; } *************** *** 200,204 **** SelfType &operator--() { ! decrement(); return *this; } --- 200,204 ---- SelfType &operator--() { ! this->decrement(); return *this; } *************** *** 213,217 **** SelfType &operator +=( difference_type n ) { ! advance( n ); return *this; } --- 213,217 ---- SelfType &operator +=( difference_type n ) { ! this->advance( n ); return *this; } *************** *** 225,229 **** SelfType &operator -=( difference_type n ) { ! advance( -n ); return *this; } --- 225,229 ---- SelfType &operator -=( difference_type n ) { ! this->advance( -n ); return *this; } *************** *** 242,251 **** reference operator *() const { ! return deref(); } pointer operator->() const { ! return &deref(); } --- 242,251 ---- reference operator *() const { ! return this->deref(); } pointer operator->() const { ! return &(this->deref()); } *************** *** 284,293 **** , allocator_( other.allocator_ ) { ! data_ = allocator_.allocateArray( size_ ); CPPTL_TRY_BEGIN { ! ::CppTL::Impl::copy_with_construct( other.begin(), other.end(), data_ ); } ! CPPTL_TRY_END_CLEANUP( allocator.releaseArray( data_, size_ ) ) } --- 284,293 ---- , allocator_( other.allocator_ ) { ! this->data_ = allocator_.allocateArray( this->size_ ); CPPTL_TRY_BEGIN { ! ::CppTL::Impl::copy_with_construct( other.begin(), other.end(), this->data_ ); } ! CPPTL_TRY_END_CLEANUP( allocator.releaseArray( this->data_, this->size_ ) ) } *************** *** 305,309 **** size_t size() const { ! return size_; } --- 305,309 ---- size_t size() const { ! return this->size_; } *************** *** 370,399 **** iterator begin() { ! return iterator( *this, data_ ); } iterator end() { ! return iterator( *this, size_ ); } const_iterator begin() const { ! return const_iterator( *this, data_ ); } const_iterator end() const { ! return const_iterator( *this, size_ ); } size_t count( const Key &key ) const { ! return lookUp( key) ? 1 : 0; } bool empty() const { ! return size_ == 0; } --- 370,399 ---- iterator begin() { ! return iterator( *this, this->data_ ); } iterator end() { ! return iterator( *this, this->size_ ); } const_iterator begin() const { ! return const_iterator( *this, this->data_ ); } const_iterator end() const { ! return const_iterator( *this, this->size_ ); } size_t count( const Key &key ) const { ! return lookUp( key ) ? 1 : 0; } bool empty() const { ! return this->size_ == 0; } *************** *** 404,408 **** CPPTL_ASSERT_MESSAGE( where >= begin() && where < end(), "SmallMap<T>::erase(): invalid iterator" ); ::CppTL::Impl::copy_and_destroy( where+1, end(), where ); ! --size_; return where; } --- 404,408 ---- CPPTL_ASSERT_MESSAGE( where >= begin() && where < end(), "SmallMap<T>::erase(): invalid iterator" ); ::CppTL::Impl::copy_and_destroy( where+1, end(), where ); ! --(this->size_); return where; } *************** *** 413,417 **** size_t count = last - first; ::CppTL::Impl::copy_and_destroy( last, end(), first ); ! size_ -= count; return iterator( *this, whereIndex ); } --- 413,417 ---- size_t count = last - first; ::CppTL::Impl::copy_and_destroy( last, end(), first ); ! this->size_ -= count; return iterator( *this, whereIndex ); } *************** *** 429,436 **** typedef Pair<iterator,bool> ResultType; size_t whereIndex = insertionIndex( key, 0 ); ! if ( whereIndex < size_ ! && !less_( key, data_[whereIndex].first ) ) { ! return data_[whereIndex].second; } return doInsert( whereIndex, Item( key, Value() ) )->second; --- 429,436 ---- typedef Pair<iterator,bool> ResultType; size_t whereIndex = insertionIndex( key, 0 ); ! if ( whereIndex < this->size_ ! && !less_( key, this->data_[whereIndex].first ) ) { ! return this->data_[whereIndex].second; } return doInsert( whereIndex, Item( key, Value() ) )->second; *************** *** 441,446 **** typedef Pair<iterator,bool> ResultType; size_t whereIndex = insertionIndex( item.first, 0 ); ! if ( whereIndex < size_ ! && !less_( item.first, data_[whereIndex].first ) ) { return ResultType( iterator( *this, whereIndex ), false ); --- 441,446 ---- typedef Pair<iterator,bool> ResultType; size_t whereIndex = insertionIndex( item.first, 0 ); ! if ( whereIndex < this->size_ ! && !less_( item.first, this->data_[whereIndex].first ) ) { return ResultType( iterator( *this, whereIndex ), false ); *************** *** 452,461 **** { size_t whereIndex = insertionIndex( item.first, where.index() ); ! if ( size_ == capacity_ ) { if ( reserve( 1, whereIndex, &item ) ) // element was inserted when increasing capacity. return iterator( *this, whereIndex ); } ! ++size_; iterator itWhere( *this, whereIndex ); ::CppTL::Impl::copy_backwards_and_destroy( itWhere, end()-1, end() ); --- 452,461 ---- { size_t whereIndex = insertionIndex( item.first, where.index() ); ! if ( this->size_ == this->capacity_ ) { if ( reserve( 1, whereIndex, &item ) ) // element was inserted when increasing capacity. return iterator( *this, whereIndex ); } ! ++(this->size_); iterator itWhere( *this, whereIndex ); ::CppTL::Impl::copy_backwards_and_destroy( itWhere, end()-1, end() ); *************** *** 474,480 **** void swap( SelfType &other ) { ! CppTL::swap( data_, other.data_ ); ! CppTL::swap( size_, other.size_ ); ! CppTL::swap( capacity_, other.capacity_ ); allocator_.swap( other.allocator_ ); CppTL::swap( less_, other.less_ ); --- 474,480 ---- void swap( SelfType &other ) { ! CppTL::swap( this->data_, other.data_ ); ! CppTL::swap( this->size_, other.size_ ); ! CppTL::swap( this->capacity_, other.capacity_ ); allocator_.swap( other.allocator_ ); CppTL::swap( less_, other.less_ ); *************** *** 483,492 **** bool operator <( const SelfType &other ) const { ! if ( size_ < other.size_ ) return true; ! if ( size_ > other.size_ || size_ == 0 ) return false; ! Item *i1 = data_, *i2 = other.data_; ! Item *i1end = data_ + size_; for ( ; i1 != i1end; ++i1, ++i2 ) { --- 483,492 ---- bool operator <( const SelfType &other ) const { ! if ( this->size_ < other.size_ ) return true; ! if ( this->size_ > other.size_ || this->size_ == 0 ) return false; ! Item *i1 = this->data_, *i2 = other.data_; ! Item *i1end = this->data_ + this->size_; for ( ; i1 != i1end; ++i1, ++i2 ) { *************** *** 501,508 **** bool operator ==( const SelfType &other ) const { ! if ( size_ != other.size_ ) return false; ! Item *i1 = data_, *i2 = other.data_; ! Item *i1end = data_ + size_; for ( ; i1 != i1end; ++i1, ++i2 ) { --- 501,508 ---- bool operator ==( const SelfType &other ) const { ! if ( this->size_ != other.size_ ) return false; ! Item *i1 = this->data_, *i2 = other.data_; ! Item *i1end = this->data_ + this->size_; for ( ; i1 != i1end; ++i1, ++i2 ) { *************** *** 518,526 **** bool reserve( size_t count, size_t insertIndex = 0, const Item *item = 0) { ! if ( size_ + count <= capacity_ ) return false; const size_t initialCapacity = 8; const size_t minCapacityIncrement = 8; ! size_t newCapacity = size_ + count; newCapacity += CPPTL_MAX( newCapacity / 4, minCapacityIncrement ); newCapacity = CPPTL_MAX( initialCapacity, newCapacity ); --- 518,526 ---- bool reserve( size_t count, size_t insertIndex = 0, const Item *item = 0) { ! if ( this->size_ + count <= this->capacity_ ) return false; const size_t initialCapacity = 8; const size_t minCapacityIncrement = 8; ! size_t newCapacity = this->size_ + count; newCapacity += CPPTL_MAX( newCapacity / 4, minCapacityIncrement ); newCapacity = CPPTL_MAX( initialCapacity, newCapacity ); *************** *** 529,533 **** { if ( !item ) ! insertIndex = size_; ::CppTL::Impl::copy_and_destroy( begin(), begin() + insertIndex, newData ); if ( item ) --- 529,533 ---- { if ( !item ) ! insertIndex = this->size_; ::CppTL::Impl::copy_and_destroy( begin(), begin() + insertIndex, newData ); if ( item ) *************** *** 539,548 **** } CPPTL_TRY_END_CLEANUP( allocator_.release( newData, newCapacity ) ); ! if ( data_ ) ! allocator_.releaseArray( data_, capacity_ ); ! data_ = newData; ! capacity_ = newCapacity; if ( item ) ! ++size_; return true; } --- 539,548 ---- } CPPTL_TRY_END_CLEANUP( allocator_.release( newData, newCapacity ) ); ! if ( this->data_ ) ! allocator_.releaseArray( this->data_, this->capacity_ ); ! this->data_ = newData; ! this->capacity_ = newCapacity; if ( item ) ! ++(this->size_); return true; } *************** *** 550,558 **** size_t insertionIndex( const Key &key, size_t min = 0 ) const { ! size_t max = size_; while ( min != max ) { size_t mid = (max+min) / 2; ! if ( less_( data_[mid].first, key ) ) min = mid + 1; else --- 550,558 ---- size_t insertionIndex( const Key &key, size_t min = 0 ) const { ! size_t max = this->size_; while ( min != max ) { size_t mid = (max+min) / 2; ! if ( less_( this->data_[mid].first, key ) ) min = mid + 1; else *************** *** 565,570 **** { size_t pos = insertionIndex( key, 0 ); ! if ( pos < size_ && !less_( key, data_[pos].first ) ) ! return data_ + pos; return 0; } --- 565,570 ---- { size_t pos = insertionIndex( key, 0 ); ! if ( pos < this->size_ && !less_( key, this->data_[pos].first ) ) ! return this->data_ + pos; return 0; } *************** *** 572,584 **** iterator doInsert( size_t whereIndex, const Item &item ) { ! if ( size_ == capacity_ ) { if ( reserve( 1, whereIndex, &item ) ) // element was inserted when increasing capacity. return begin() + whereIndex; } ! ++size_; iterator itWhere( *this, whereIndex ); iterator itEnd = end(); ! if ( whereIndex != size_ - 1 ) ::CppTL::Impl::copy_backwards_and_destroy( itWhere, itEnd-1, itEnd ); ::CppTL::Impl::construct( *itWhere, item); --- 572,584 ---- iterator doInsert( size_t whereIndex, const Item &item ) { ! if ( this->size_ == this->capacity_ ) { if ( reserve( 1, whereIndex, &item ) ) // element was inserted when increasing capacity. return begin() + whereIndex; } ! ++(this->size_); iterator itWhere( *this, whereIndex ); iterator itEnd = end(); ! if ( whereIndex != this->size_ - 1 ) ::CppTL::Impl::copy_backwards_and_destroy( itWhere, itEnd-1, itEnd ); ::CppTL::Impl::construct( *itWhere, item); |