This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] Qualify with std:: three more files...


Hi all, hi Gaby,

I'd like to commit soon the below, tested x86-linux.

Ok with you, Gaby?

Paolo.

/////////
2003-07-01  Paolo Carlini  <pcarlini@unitus.it>

	* include/bits/stl_bvector.h: Fully qualify standard
	functions with std::, thus avoiding Koenig lookup.
	* include/bits/stl_construct.h: Likewise.
	* include/bits/stl_deque.h: Likewise.

diff -cprN libstdc++-v3-orig/include/bits/stl_bvector.h libstdc++-v3/include/bits/stl_bvector.h
*** libstdc++-v3-orig/include/bits/stl_bvector.h	Tue Jun 10 23:52:23 2003
--- libstdc++-v3/include/bits/stl_bvector.h	Tue Jul  1 20:32:48 2003
*************** template <typename _Alloc> 
*** 380,386 ****
      }
      void _M_insert_aux(iterator __position, bool __x) {
        if (this->_M_finish._M_p != this->_M_end_of_storage) {
!         copy_backward(__position, this->_M_finish, this->_M_finish + 1);
          *__position = __x;
          ++this->_M_finish;
        }
--- 380,386 ----
      }
      void _M_insert_aux(iterator __position, bool __x) {
        if (this->_M_finish._M_p != this->_M_end_of_storage) {
!         std::copy_backward(__position, this->_M_finish, this->_M_finish + 1);
          *__position = __x;
          ++this->_M_finish;
        }
*************** template <typename _Alloc> 
*** 388,396 ****
          size_type __len = size() 
  	                  ? 2 * size() : static_cast<size_type>(_S_word_bit);
          _Bit_type * __q = _M_bit_alloc(__len);
!         iterator __i = copy(begin(), __position, iterator(__q, 0));
          *__i++ = __x;
!         this->_M_finish = copy(__position, end(), __i);
          _M_deallocate();
          this->_M_end_of_storage = __q + (__len + _S_word_bit - 1)/_S_word_bit;
          this->_M_start = iterator(__q, 0);
--- 388,396 ----
          size_type __len = size() 
  	                  ? 2 * size() : static_cast<size_type>(_S_word_bit);
          _Bit_type * __q = _M_bit_alloc(__len);
!         iterator __i = std::copy(begin(), __position, iterator(__q, 0));
          *__i++ = __x;
!         this->_M_finish = std::copy(__position, end(), __i);
          _M_deallocate();
          this->_M_end_of_storage = __q + (__len + _S_word_bit - 1)/_S_word_bit;
          this->_M_start = iterator(__q, 0);
*************** template <typename _Alloc> 
*** 412,418 ****
                               forward_iterator_tag) {
        size_type __n = std::distance(__first, __last);
        _M_initialize(__n);
!       copy(__first, __last, this->_M_start);
      }
    
      template <class _InputIterator>
--- 412,418 ----
                               forward_iterator_tag) {
        size_type __n = std::distance(__first, __last);
        _M_initialize(__n);
!       std::copy(__first, __last, this->_M_start);
      }
    
      template <class _InputIterator>
*************** template <typename _Alloc> 
*** 432,448 ****
        if (__first != __last) {
          size_type __n = std::distance(__first, __last);
          if (capacity() - size() >= __n) {
!           copy_backward(__position, end(),
! 			this->_M_finish + difference_type(__n));
!           copy(__first, __last, __position);
            this->_M_finish += difference_type(__n);
          }
          else {
            size_type __len = size() + std::max(size(), __n);
            _Bit_type * __q = _M_bit_alloc(__len);
!           iterator __i = copy(begin(), __position, iterator(__q, 0));
!           __i = copy(__first, __last, __i);
!           this->_M_finish = copy(__position, end(), __i);
            _M_deallocate();
            this->_M_end_of_storage
  	    = __q + (__len + _S_word_bit - 1)/_S_word_bit;
--- 432,448 ----
        if (__first != __last) {
          size_type __n = std::distance(__first, __last);
          if (capacity() - size() >= __n) {
!           std::copy_backward(__position, end(),
! 			     this->_M_finish + difference_type(__n));
!           std::copy(__first, __last, __position);
            this->_M_finish += difference_type(__n);
          }
          else {
            size_type __len = size() + std::max(size(), __n);
            _Bit_type * __q = _M_bit_alloc(__len);
!           iterator __i = std::copy(begin(), __position, iterator(__q, 0));
!           __i = std::copy(__first, __last, __i);
!           this->_M_finish = std::copy(__position, end(), __i);
            _M_deallocate();
            this->_M_end_of_storage
  	    = __q + (__len + _S_word_bit - 1)/_S_word_bit;
*************** template <typename _Alloc> 
*** 496,514 ****
        : _Bvector_base<_Alloc>(__a)
      {
        _M_initialize(__n);
!       fill(this->_M_start._M_p, this->_M_end_of_storage, __value ? ~0 : 0);
      }
    
      explicit vector(size_type __n)
        : _Bvector_base<_Alloc>(allocator_type())
      {
        _M_initialize(__n);
!       fill(this->_M_start._M_p, this->_M_end_of_storage, 0);
      }
    
      vector(const vector& __x) : _Bvector_base<_Alloc>(__x.get_allocator()) {
        _M_initialize(__x.size());
!       copy(__x.begin(), __x.end(), this->_M_start);
      }
    
      // Check whether it's an integral type.  If so, it's not an iterator.
--- 496,514 ----
        : _Bvector_base<_Alloc>(__a)
      {
        _M_initialize(__n);
!       std::fill(this->_M_start._M_p, this->_M_end_of_storage, __value ? ~0 : 0);
      }
    
      explicit vector(size_type __n)
        : _Bvector_base<_Alloc>(allocator_type())
      {
        _M_initialize(__n);
!       std::fill(this->_M_start._M_p, this->_M_end_of_storage, 0);
      }
    
      vector(const vector& __x) : _Bvector_base<_Alloc>(__x.get_allocator()) {
        _M_initialize(__x.size());
!       std::copy(__x.begin(), __x.end(), this->_M_start);
      }
    
      // Check whether it's an integral type.  If so, it's not an iterator.
*************** template <typename _Alloc> 
*** 516,522 ****
      template <class _Integer>
      void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) {
        _M_initialize(__n);
!       fill(this->_M_start._M_p, this->_M_end_of_storage, __x ? ~0 : 0);
      }
    
      template <class _InputIterator>
--- 516,522 ----
      template <class _Integer>
      void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) {
        _M_initialize(__n);
!       std::fill(this->_M_start._M_p, this->_M_end_of_storage, __x ? ~0 : 0);
      }
    
      template <class _InputIterator>
*************** template <typename _Alloc> 
*** 542,548 ****
          _M_deallocate();
          _M_initialize(__x.size());
        }
!       copy(__x.begin(), __x.end(), begin());
        this->_M_finish = begin() + difference_type(__x.size());
        return *this;
      }
--- 542,548 ----
          _M_deallocate();
          _M_initialize(__x.size());
        }
!       std::copy(__x.begin(), __x.end(), begin());
        this->_M_finish = begin() + difference_type(__x.size());
        return *this;
      }
*************** template <typename _Alloc> 
*** 554,565 ****
    
      void _M_fill_assign(size_t __n, bool __x) {
        if (__n > size()) {
!         fill(this->_M_start._M_p, this->_M_end_of_storage, __x ? ~0 : 0);
          insert(end(), __n - size(), __x);
        }
        else {
          erase(begin() + __n, end());
!         fill(this->_M_start._M_p, this->_M_end_of_storage, __x ? ~0 : 0);
        }
      }
    
--- 554,565 ----
    
      void _M_fill_assign(size_t __n, bool __x) {
        if (__n > size()) {
!         std::fill(this->_M_start._M_p, this->_M_end_of_storage, __x ? ~0 : 0);
          insert(end(), __n - size(), __x);
        }
        else {
          erase(begin() + __n, end());
!         std::fill(this->_M_start._M_p, this->_M_end_of_storage, __x ? ~0 : 0);
        }
      }
    
*************** template <typename _Alloc> 
*** 596,606 ****
                         forward_iterator_tag) {
        size_type __len = std::distance(__first, __last);
        if (__len < size())
!         erase(copy(__first, __last, begin()), end());
        else {
          _ForwardIterator __mid = __first;
!         advance(__mid, size());
!         copy(__first, __mid, begin());
          insert(end(), __mid, __last);
        }
      }    
--- 596,606 ----
                         forward_iterator_tag) {
        size_type __len = std::distance(__first, __last);
        if (__len < size())
!         erase(std::copy(__first, __last, begin()), end());
        else {
          _ForwardIterator __mid = __first;
!         std::advance(__mid, size());
!         std::copy(__first, __mid, begin());
          insert(end(), __mid, __last);
        }
      }    
*************** template <typename _Alloc> 
*** 610,616 ****
  	__throw_length_error(__N("vector::reserve"));
        if (this->capacity() < __n) {
          _Bit_type * __q = _M_bit_alloc(__n);
!         this->_M_finish = copy(begin(), end(), iterator(__q, 0));
          _M_deallocate();
          this->_M_start = iterator(__q, 0);
          this->_M_end_of_storage = __q + (__n + _S_word_bit - 1)/_S_word_bit;
--- 610,616 ----
  	__throw_length_error(__N("vector::reserve"));
        if (this->capacity() < __n) {
          _Bit_type * __q = _M_bit_alloc(__n);
!         this->_M_finish = std::copy(begin(), end(), iterator(__q, 0));
          _M_deallocate();
          this->_M_start = iterator(__q, 0);
          this->_M_end_of_storage = __q + (__n + _S_word_bit - 1)/_S_word_bit;
*************** template <typename _Alloc> 
*** 675,691 ****
      void _M_fill_insert(iterator __position, size_type __n, bool __x) {
        if (__n == 0) return;
        if (capacity() - size() >= __n) {
!         copy_backward(__position, end(),
! 		      this->_M_finish + difference_type(__n));
!         fill(__position, __position + difference_type(__n), __x);
          this->_M_finish += difference_type(__n);
        }
        else {
          size_type __len = size() + std::max(size(), __n);
          _Bit_type * __q = _M_bit_alloc(__len);
!         iterator __i = copy(begin(), __position, iterator(__q, 0));
!         fill_n(__i, __n, __x);
!         this->_M_finish = copy(__position, end(), __i + difference_type(__n));
          _M_deallocate();
          this->_M_end_of_storage = __q + (__len + _S_word_bit - 1)/_S_word_bit;
          this->_M_start = iterator(__q, 0);
--- 675,691 ----
      void _M_fill_insert(iterator __position, size_type __n, bool __x) {
        if (__n == 0) return;
        if (capacity() - size() >= __n) {
!         std::copy_backward(__position, end(),
! 			   this->_M_finish + difference_type(__n));
!         std::fill(__position, __position + difference_type(__n), __x);
          this->_M_finish += difference_type(__n);
        }
        else {
          size_type __len = size() + std::max(size(), __n);
          _Bit_type * __q = _M_bit_alloc(__len);
!         iterator __i = std::copy(begin(), __position, iterator(__q, 0));
!         std::fill_n(__i, __n, __x);
!         this->_M_finish = std::copy(__position, end(), __i + difference_type(__n));
          _M_deallocate();
          this->_M_end_of_storage = __q + (__len + _S_word_bit - 1)/_S_word_bit;
          this->_M_start = iterator(__q, 0);
*************** template <typename _Alloc> 
*** 699,710 ****
      void pop_back() { --this->_M_finish; }
      iterator erase(iterator __position) {
        if (__position + 1 != end())
!         copy(__position + 1, end(), __position);
          --this->_M_finish;
        return __position;
      }
      iterator erase(iterator __first, iterator __last) {
!       this->_M_finish = copy(__last, end(), __first);
        return __first;
      }
      void resize(size_type __new_size, bool __x = bool()) {
--- 699,710 ----
      void pop_back() { --this->_M_finish; }
      iterator erase(iterator __position) {
        if (__position + 1 != end())
!         std::copy(__position + 1, end(), __position);
          --this->_M_finish;
        return __position;
      }
      iterator erase(iterator __first, iterator __last) {
!       this->_M_finish = std::copy(__last, end(), __first);
        return __first;
      }
      void resize(size_type __new_size, bool __x = bool()) {
diff -cprN libstdc++-v3-orig/include/bits/stl_construct.h libstdc++-v3/include/bits/stl_construct.h
*** libstdc++-v3-orig/include/bits/stl_construct.h	Wed Mar 27 22:41:32 2002
--- libstdc++-v3/include/bits/stl_construct.h	Tue Jul  1 20:35:48 2003
*************** namespace std
*** 90,95 ****
--- 90,105 ----
  
    /**
     * @if maint
+    * Destroy the object pointed to by a pointer type.
+    * @endif
+    */
+   template <class _Tp>
+     inline void
+     _Destroy(_Tp* __pointer)
+     { __pointer->~_Tp(); }
+ 
+   /**
+    * @if maint
     * Destroy a range of objects with nontrivial destructors.  
     *
     * This is a helper function used only by _Destroy().
*************** namespace std
*** 98,104 ****
    template <class _ForwardIterator>
      inline void
      __destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type)
!     { for ( ; __first != __last; ++__first) _Destroy(&*__first); }
  
    /**
     * @if maint
--- 108,114 ----
    template <class _ForwardIterator>
      inline void
      __destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __false_type)
!     { for ( ; __first != __last; ++__first) std::_Destroy(&*__first); }
  
    /**
     * @if maint
*************** namespace std
*** 116,131 ****
  
    /**
     * @if maint
-    * Destroy the object pointed to by a pointer type.
-    * @endif
-    */
-   template <class _Tp>
-     inline void
-     _Destroy(_Tp* __pointer)
-     { __pointer->~_Tp(); }
-   
-   /**
-    * @if maint
     * Destroy a range of objects.  If the value_type of the object has
     * a trivial destructor, the compiler should optimize all of this
     * away, otherwise the objects' destructors must be invoked.
--- 126,131 ----
*************** namespace std
*** 140,146 ****
        typedef typename __type_traits<_Value_type>::has_trivial_destructor
                         _Has_trivial_destructor;
  
!       __destroy_aux(__first, __last, _Has_trivial_destructor());
      }
  } // namespace std
  
--- 140,146 ----
        typedef typename __type_traits<_Value_type>::has_trivial_destructor
                         _Has_trivial_destructor;
  
!       std::__destroy_aux(__first, __last, _Has_trivial_destructor());
      }
  } // namespace std
  
diff -cprN libstdc++-v3-orig/include/bits/stl_deque.h libstdc++-v3/include/bits/stl_deque.h
*** libstdc++-v3-orig/include/bits/stl_deque.h	Wed Jun 11 17:52:09 2003
--- libstdc++-v3/include/bits/stl_deque.h	Tue Jul  1 21:20:40 2003
*************** namespace std
*** 723,729 ****
      */
      deque(const deque& __x)
        : _Base(__x.get_allocator(), __x.size()) 
!       { uninitialized_copy(__x.begin(), __x.end(), this->_M_start); }
    
      /**
       *  @brief  Builds a %deque from a range.
--- 723,729 ----
      */
      deque(const deque& __x)
        : _Base(__x.get_allocator(), __x.size()) 
!       { std::uninitialized_copy(__x.begin(), __x.end(), this->_M_start); }
    
      /**
       *  @brief  Builds a %deque from a range.
*************** namespace std
*** 753,759 ****
       *  themselves are pointers, the pointed-to memory is not touched in any
       *  way.  Managing the pointer is the user's responsibilty.
      */
!     ~deque() { _Destroy(this->_M_start, this->_M_finish); }
    
      /**
       *  @brief  %Deque assignment operator.
--- 753,759 ----
       *  themselves are pointers, the pointed-to memory is not touched in any
       *  way.  Managing the pointer is the user's responsibilty.
      */
!     ~deque() { std::_Destroy(this->_M_start, this->_M_finish); }
    
      /**
       *  @brief  %Deque assignment operator.
*************** namespace std
*** 1021,1027 ****
      push_front(const value_type& __x) 
      {
        if (this->_M_start._M_cur != this->_M_start._M_first) {
!         _Construct(this->_M_start._M_cur - 1, __x);
          --this->_M_start._M_cur;
        }
        else
--- 1021,1027 ----
      push_front(const value_type& __x) 
      {
        if (this->_M_start._M_cur != this->_M_start._M_first) {
!         std::_Construct(this->_M_start._M_cur - 1, __x);
          --this->_M_start._M_cur;
        }
        else
*************** namespace std
*** 1040,1046 ****
      push_back(const value_type& __x)
      {
        if (this->_M_finish._M_cur != this->_M_finish._M_last - 1) {
!         _Construct(this->_M_finish._M_cur, __x);
          ++this->_M_finish._M_cur;
        }
        else
--- 1040,1046 ----
      push_back(const value_type& __x)
      {
        if (this->_M_finish._M_cur != this->_M_finish._M_last - 1) {
!         std::_Construct(this->_M_finish._M_cur, __x);
          ++this->_M_finish._M_cur;
        }
        else
*************** namespace std
*** 1059,1065 ****
      pop_front()
      {
        if (this->_M_start._M_cur != this->_M_start._M_last - 1) {
!         _Destroy(this->_M_start._M_cur);
          ++this->_M_start._M_cur;
        }
        else 
--- 1059,1065 ----
      pop_front()
      {
        if (this->_M_start._M_cur != this->_M_start._M_last - 1) {
!         std::_Destroy(this->_M_start._M_cur);
          ++this->_M_start._M_cur;
        }
        else 
*************** namespace std
*** 1079,1085 ****
      {
        if (this->_M_finish._M_cur != this->_M_finish._M_first) {
          --this->_M_finish._M_cur;
!         _Destroy(this->_M_finish._M_cur);
        }
        else
          _M_pop_back_aux();
--- 1079,1085 ----
      {
        if (this->_M_finish._M_cur != this->_M_finish._M_first) {
          --this->_M_finish._M_cur;
!         std::_Destroy(this->_M_finish._M_cur);
        }
        else
          _M_pop_back_aux();
*************** namespace std
*** 1292,1303 ****
          size_type __len = std::distance(__first, __last);
          if (__len > size()) {
            _ForwardIterator __mid = __first;
!           advance(__mid, size());
!           copy(__first, __mid, begin());
            insert(end(), __mid, __last);
          }
          else
!           erase(copy(__first, __last, begin()), end());
        }
    
      // Called by assign(n,t), and the range assign when it turns out to be the
--- 1292,1303 ----
          size_type __len = std::distance(__first, __last);
          if (__len > size()) {
            _ForwardIterator __mid = __first;
!           std::advance(__mid, size());
!           std::copy(__first, __mid, begin());
            insert(end(), __mid, __last);
          }
          else
!           erase(std::copy(__first, __last, begin()), end());
        }
    
      // Called by assign(n,t), and the range assign when it turns out to be the
*************** namespace std
*** 1307,1319 ****
      {
        if (__n > size())
        {
!         fill(begin(), end(), __val);
          insert(end(), __n - size(), __val);
        }
        else
        {
          erase(begin() + __n, end());
!         fill(begin(), end(), __val);
        }
      }
    
--- 1307,1319 ----
      {
        if (__n > size())
        {
!         std::fill(begin(), end(), __val);
          insert(end(), __n - size(), __val);
        }
        else
        {
          erase(begin() + __n, end());
!         std::fill(begin(), end(), __val);
        }
      }
    
*************** namespace std
*** 1469,1475 ****
                           const deque<_Tp, _Alloc>& __y)
    {
      return __x.size() == __y.size() &&
!            equal(__x.begin(), __x.end(), __y.begin());
    }
    
    /**
--- 1469,1475 ----
                           const deque<_Tp, _Alloc>& __y)
    {
      return __x.size() == __y.size() &&
!            std::equal(__x.begin(), __x.end(), __y.begin());
    }
    
    /**

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]