stl_bvector.h (operator==(const _Bit_iterator_base&, const _Bit_iterator_base&))...
authorFrançois Dumont <fdumont@gcc.gnu.org>
Sat, 11 May 2019 13:29:05 +0000 (13:29 +0000)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Sat, 11 May 2019 13:29:05 +0000 (13:29 +0000)
2019-05-11  François Dumont  <fdumont@gcc.gnu.org>

* include/bits/stl_bvector.h
(operator==(const _Bit_iterator_base&, const _Bit_iterator_base&)):
Make hidden friend.
(operator<(const _Bit_iterator_base&, const _Bit_iterator_base&)):
Likewise.
(operator!=(const _Bit_iterator_base&, const _Bit_iterator_base&)):
Likewise.
(operator>(const _Bit_iterator_base&, const _Bit_iterator_base&)):
Likewise.
(operator<=(const _Bit_iterator_base&, const _Bit_iterator_base&)):
Likewise.
(operator>=(const _Bit_iterator_base&, const _Bit_iterator_base&)):
Likewise.
(operator-(const _Bit_iterator_base&, const _Bit_iterator_base&)):
Likewise.
(_Bit_iterator::operator+(difference_type)): Likewise and allow NRVO
copy elision.
(_Bit_iterator::operator-(difference_type)): Likewise.
(operator+(ptrdiff_t, const _Bit_iterator&)): Make hidden friend.
(_Bit_const_iterator::operator+(difference_type)): Likewise and allow
NRVO copy elision.
(_Bit_const_iterator::operator-(difference_type)): Likewise.
(operator+(ptrdiff_t, const _Bit_const_iterator&)): Make hidden friend.

From-SVN: r271096

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_bvector.h

index ee7bcdc24a5790fa05022aa3869cbddaf22a0572..50633c89f2fab20b2621dcab55b4cc3f076f9a43 100644 (file)
@@ -1,3 +1,29 @@
+2019-05-11  François Dumont  <fdumont@gcc.gnu.org>
+
+       * include/bits/stl_bvector.h
+       (operator==(const _Bit_iterator_base&, const _Bit_iterator_base&)):
+       Make hidden friend.
+       (operator<(const _Bit_iterator_base&, const _Bit_iterator_base&)):
+       Likewise.
+       (operator!=(const _Bit_iterator_base&, const _Bit_iterator_base&)):
+       Likewise.
+       (operator>(const _Bit_iterator_base&, const _Bit_iterator_base&)):
+       Likewise.
+       (operator<=(const _Bit_iterator_base&, const _Bit_iterator_base&)):
+       Likewise.
+       (operator>=(const _Bit_iterator_base&, const _Bit_iterator_base&)):
+       Likewise.
+       (operator-(const _Bit_iterator_base&, const _Bit_iterator_base&)):
+       Likewise.
+       (_Bit_iterator::operator+(difference_type)): Likewise and allow NRVO
+       copy elision.
+       (_Bit_iterator::operator-(difference_type)): Likewise.
+       (operator+(ptrdiff_t, const _Bit_iterator&)): Make hidden friend.
+       (_Bit_const_iterator::operator+(difference_type)): Likewise and allow
+       NRVO copy elision.
+       (_Bit_const_iterator::operator-(difference_type)): Likewise.
+       (operator+(ptrdiff_t, const _Bit_const_iterator&)): Make hidden friend.
+
 2019-05-10  Jonathan Wakely  <jwakely@redhat.com>
 
        PR libstdc++/81266
index c60f4f0ef1c9b80fa6c1c04edcf7eabfa63f20fd..280d40f60c51fbe16bef5691515b521d0b4e049b 100644 (file)
@@ -182,40 +182,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       _M_offset = static_cast<unsigned int>(__n);
     }
 
-    bool
-    operator==(const _Bit_iterator_base& __i) const
-    { return _M_p == __i._M_p && _M_offset == __i._M_offset; }
+    friend bool
+    operator==(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
+    { return __x._M_p == __y._M_p && __x._M_offset == __y._M_offset; }
 
-    bool
-    operator<(const _Bit_iterator_base& __i) const
+    friend bool
+    operator<(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
     {
-      return _M_p < __i._M_p
-           || (_M_p == __i._M_p && _M_offset < __i._M_offset);
+      return __x._M_p < __y._M_p
+           || (__x._M_p == __y._M_p && __x._M_offset < __y._M_offset);
     }
 
-    bool
-    operator!=(const _Bit_iterator_base& __i) const
-    { return !(*this == __i); }
+    friend bool
+    operator!=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
+    { return !(__x == __y); }
 
-    bool
-    operator>(const _Bit_iterator_base& __i) const
-    { return __i < *this; }
+    friend bool
+    operator>(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
+    { return __y < __x; }
 
-    bool
-    operator<=(const _Bit_iterator_base& __i) const
-    { return !(__i < *this); }
+    friend bool
+    operator<=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
+    { return !(__y < __x); }
 
-    bool
-    operator>=(const _Bit_iterator_base& __i) const
-    { return !(*this < __i); }
-  };
+    friend bool
+    operator>=(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
+    { return !(__x < __y); }
 
-  inline ptrdiff_t
-  operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
-  {
-    return (int(_S_word_bit) * (__x._M_p - __y._M_p)
-           + __x._M_offset - __y._M_offset);
-  }
+    friend ptrdiff_t
+    operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y)
+    {
+      return (int(_S_word_bit) * (__x._M_p - __y._M_p)
+             + __x._M_offset - __y._M_offset);
+    }
+  };
 
   struct _Bit_iterator : public _Bit_iterator_base
   {
@@ -280,29 +280,31 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       return *this;
     }
 
-    iterator
-    operator+(difference_type __i) const
+    reference
+    operator[](difference_type __i) const
+    { return *(*this + __i); }
+
+    friend iterator
+    operator+(const iterator& __x, difference_type __n)
     {
-      iterator __tmp = *this;
-      return __tmp += __i;
+      iterator __tmp = __x;
+      __tmp += __n;
+      return __tmp;
     }
 
-    iterator
-    operator-(difference_type __i) const
+    friend iterator
+    operator+(difference_type __n, const iterator& __x)
+    { return __x + __n; }
+
+    friend iterator
+    operator-(const iterator& __x, difference_type __n)
     {
-      iterator __tmp = *this;
-      return __tmp -= __i;
+      iterator __tmp = __x;
+      __tmp -= __n;
+      return __tmp;
     }
-
-    reference
-    operator[](difference_type __i) const
-    { return *(*this + __i); }
   };
 
-  inline _Bit_iterator
-  operator+(ptrdiff_t __n, const _Bit_iterator& __x)
-  { return __x + __n; }
-
   struct _Bit_const_iterator : public _Bit_iterator_base
   {
     typedef bool                 reference;
@@ -370,29 +372,31 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       return *this;
     }
 
-    const_iterator
-    operator+(difference_type __i) const
+    const_reference
+    operator[](difference_type __i) const
+    { return *(*this + __i); }
+
+    friend const_iterator
+    operator+(const const_iterator& __x, difference_type __n)
     {
-      const_iterator __tmp = *this;
-      return __tmp += __i;
+      const_iterator __tmp = __x;
+      __tmp += __n;
+      return __tmp;
     }
 
-    const_iterator
-    operator-(difference_type __i) const
+    friend const_iterator
+    operator-(const const_iterator& __x, difference_type __n)
     {
-      const_iterator __tmp = *this;
-      return __tmp -= __i;
+      const_iterator __tmp = __x;
+      __tmp -= __n;
+      return __tmp;
     }
 
-    const_reference
-    operator[](difference_type __i) const
-    { return *(*this + __i); }
+    friend const_iterator
+    operator+(difference_type __n, const const_iterator& __x)
+    { return __x + __n; }
   };
 
-  inline _Bit_const_iterator
-  operator+(ptrdiff_t __n, const _Bit_const_iterator& __x)
-  { return __x + __n; }
-
   inline void
   __fill_bvector(_Bit_type * __v,
                 unsigned int __first, unsigned int __last, bool __x)