Remove some more using-declarations from namespace __gnu_cxx
authorJonathan Wakely <jwakely@redhat.com>
Wed, 30 Oct 2019 15:48:23 +0000 (15:48 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Wed, 30 Oct 2019 15:48:23 +0000 (15:48 +0000)
Similar to some recent patches, this removes using-declarations for
names from namespace std, so that they are not redeclared in __gnu_cxx.

* include/bits/stl_iterator.h (namespace __gnu_cxx): Remove
using-declarations for std::iterator and std::iterator_traits.
(__gnu_cxx::__normal_iterator): Qualify iterator_traits.
* include/ext/algorithm (namespace __gnu_cxx): Remove
using-declarations for std names and qualify those names when used.
Also refer to std::min in parentheses to protect against function-like
macros.
* include/ext/rc_string_base.h: Qualify iterator_traits.
* include/ext/sso_string_base.h: Qualify iterator_traits.

From-SVN: r277630

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_iterator.h
libstdc++-v3/include/ext/algorithm
libstdc++-v3/include/ext/rc_string_base.h
libstdc++-v3/include/ext/sso_string_base.h

index 12eca8f8138c9a7eab3333615c41bf3dc280c525..7d7159a5d3c0ec937f1be59ced0f6a5605840d60 100644 (file)
@@ -1,5 +1,15 @@
 2019-10-30  Jonathan Wakely  <jwakely@redhat.com>
 
+       * include/bits/stl_iterator.h (namespace __gnu_cxx): Remove
+       using-declarations for std::iterator and std::iterator_traits.
+       (__gnu_cxx::__normal_iterator): Qualify iterator_traits.
+       * include/ext/algorithm (namespace __gnu_cxx): Remove
+       using-declarations for std names and qualify those names when used.
+       Also refer to std::min in parentheses to protect against function-like
+       macros.
+       * include/ext/rc_string_base.h: Qualify iterator_traits.
+       * include/ext/sso_string_base.h: Qualify iterator_traits.
+
        PR libstdc++/92272
        * include/bits/stl_bvector.h (_Bit_iterator::pointer)
        (_Bit_const_iterator::pointer): Define as void for C++20.
index 2a3b023107970d3f917e19c77e8a791a100bb3b4..ecc06178c3489d8ffba9c871555dfff0f5dd9aa2 100644 (file)
@@ -793,15 +793,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // The _Container parameter exists solely so that different containers
   // using this template can instantiate different types, even if the
   // _Iterator parameter is the same.
-  using std::iterator_traits;
-  using std::iterator;
   template<typename _Iterator, typename _Container>
     class __normal_iterator
     {
     protected:
       _Iterator _M_current;
 
-      typedef iterator_traits<_Iterator>               __traits_type;
+      typedef std::iterator_traits<_Iterator>          __traits_type;
 
     public:
       typedef _Iterator                                        iterator_type;
index 2970b7d8dfed2364e916b070a20772fbe7f1021d..ec244d9186084ef05d93d155cf1d89314e1c04c1 100644 (file)
@@ -64,21 +64,14 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-  using std::ptrdiff_t;
-  using std::min;
-  using std::pair;
-  using std::input_iterator_tag;
-  using std::random_access_iterator_tag;
-  using std::iterator_traits;
-
   //--------------------------------------------------
   // copy_n (not part of the C++ standard)
 
   template<typename _InputIterator, typename _Size, typename _OutputIterator>
-    pair<_InputIterator, _OutputIterator>
+    std::pair<_InputIterator, _OutputIterator>
     __copy_n(_InputIterator __first, _Size __count,
             _OutputIterator __result,
-            input_iterator_tag)
+            std::input_iterator_tag)
     {
       for ( ; __count > 0; --__count)
        {
@@ -86,17 +79,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
          ++__first;
          ++__result;
        }
-      return pair<_InputIterator, _OutputIterator>(__first, __result);
+      return std::pair<_InputIterator, _OutputIterator>(__first, __result);
     }
 
   template<typename _RAIterator, typename _Size, typename _OutputIterator>
-    inline pair<_RAIterator, _OutputIterator>
+    inline std::pair<_RAIterator, _OutputIterator>
     __copy_n(_RAIterator __first, _Size __count,
             _OutputIterator __result,
-            random_access_iterator_tag)
+            std::random_access_iterator_tag)
     {
       _RAIterator __last = __first + __count;
-      return pair<_RAIterator, _OutputIterator>(__last, std::copy(__first,
+      return std::pair<_RAIterator, _OutputIterator>(__last, std::copy(__first,
                                                                  __last,
                                                                  __result));
     }
@@ -116,13 +109,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    *  @ingroup SGIextensions
   */
   template<typename _InputIterator, typename _Size, typename _OutputIterator>
-    inline pair<_InputIterator, _OutputIterator>
+    inline std::pair<_InputIterator, _OutputIterator>
     copy_n(_InputIterator __first, _Size __count, _OutputIterator __result)
     {
       // concept requirements
       __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
       __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
-           typename iterator_traits<_InputIterator>::value_type>)
+           typename std::iterator_traits<_InputIterator>::value_type>)
 
       return __gnu_cxx::__copy_n(__first, __count, __result,
                                 std::__iterator_category(__first));
@@ -156,10 +149,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                                 const unsigned char* __first2,
                                 const unsigned char* __last2)
   {
-    const ptrdiff_t __len1 = __last1 - __first1;
-    const ptrdiff_t __len2 = __last2 - __first2;
+    const std::ptrdiff_t __len1 = __last1 - __first1;
+    const std::ptrdiff_t __len2 = __last2 - __first2;
     const int __result = __builtin_memcmp(__first1, __first2,
-                                         min(__len1, __len2));
+                                         (std::min)(__len1, __len2));
     return __result != 0 ? __result
                         : (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
   }
@@ -207,9 +200,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
       __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
       __glibcxx_function_requires(_LessThanComparableConcept<
-           typename iterator_traits<_InputIterator1>::value_type>)
+           typename std::iterator_traits<_InputIterator1>::value_type>)
       __glibcxx_function_requires(_LessThanComparableConcept<
-           typename iterator_traits<_InputIterator2>::value_type>)
+           typename std::iterator_traits<_InputIterator2>::value_type>)
       __glibcxx_requires_valid_range(__first1, __last1);
       __glibcxx_requires_valid_range(__first2, __last2);
 
@@ -228,7 +221,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // concept requirements
       __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
       __glibcxx_function_requires(_EqualityComparableConcept<
-           typename iterator_traits<_InputIterator>::value_type >)
+           typename std::iterator_traits<_InputIterator>::value_type >)
       __glibcxx_function_requires(_EqualityComparableConcept<_Tp>)
       __glibcxx_requires_valid_range(__first, __last);
 
@@ -246,7 +239,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // concept requirements
       __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
       __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
-           typename iterator_traits<_InputIterator>::value_type>)
+           typename std::iterator_traits<_InputIterator>::value_type>)
       __glibcxx_requires_valid_range(__first, __last);
 
       for ( ; __first != __last; ++__first)
@@ -270,11 +263,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // concept requirements
       __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
       __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
-               typename iterator_traits<_ForwardIterator>::value_type>)
+               typename std::iterator_traits<_ForwardIterator>::value_type>)
       __glibcxx_requires_valid_range(__first, __last);
 
       _Distance __remaining = std::distance(__first, __last);
-      _Distance __m = min(__n, __remaining);
+      _Distance __m = (std::min)(__n, __remaining);
 
       while (__m > 0)
        {
@@ -305,13 +298,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // concept requirements
       __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
       __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
-               typename iterator_traits<_ForwardIterator>::value_type>)
+               typename std::iterator_traits<_ForwardIterator>::value_type>)
       __glibcxx_function_requires(_UnaryFunctionConcept<
                _RandomNumberGenerator, _Distance, _Distance>)
       __glibcxx_requires_valid_range(__first, __last);
 
       _Distance __remaining = std::distance(__first, __last);
-      _Distance __m = min(__n, __remaining);
+      _Distance __m = (std::min)(__n, __remaining);
 
       while (__m > 0)
        {
@@ -441,7 +434,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __glibcxx_function_requires(_RandomAccessIteratorConcept<
                                  _RandomAccessIterator>)
       __glibcxx_function_requires(_LessThanComparableConcept<
-           typename iterator_traits<_RandomAccessIterator>::value_type>)
+           typename std::iterator_traits<_RandomAccessIterator>::value_type>)
       __glibcxx_requires_valid_range(__first, __last);
 
       return std::__is_heap(__first, __last - __first);
@@ -461,8 +454,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __glibcxx_function_requires(_RandomAccessIteratorConcept<
                                  _RandomAccessIterator>)
       __glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering,
-           typename iterator_traits<_RandomAccessIterator>::value_type,
-           typename iterator_traits<_RandomAccessIterator>::value_type>)
+           typename std::iterator_traits<_RandomAccessIterator>::value_type,
+           typename std::iterator_traits<_RandomAccessIterator>::value_type>)
       __glibcxx_requires_valid_range(__first, __last);
 
       return std::__is_heap(__first, __comp, __last - __first);
@@ -488,7 +481,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // concept requirements
       __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
       __glibcxx_function_requires(_LessThanComparableConcept<
-           typename iterator_traits<_ForwardIterator>::value_type>)
+           typename std::iterator_traits<_ForwardIterator>::value_type>)
       __glibcxx_requires_valid_range(__first, __last);
 
       if (__first == __last)
@@ -514,8 +507,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // concept requirements
       __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
       __glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering,
-           typename iterator_traits<_ForwardIterator>::value_type,
-           typename iterator_traits<_ForwardIterator>::value_type>)
+           typename std::iterator_traits<_ForwardIterator>::value_type,
+           typename std::iterator_traits<_ForwardIterator>::value_type>)
       __glibcxx_requires_valid_range(__first, __last);
 
       if (__first == __last)
index 2cf5fb0c5e3d14d21b19e62c3027d0944feb21f0..3a902d6a18ae333954202aa581d311dac2098d11 100644 (file)
@@ -231,7 +231,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        _S_construct_aux(_InIterator __beg, _InIterator __end,
                         const _Alloc& __a, std::__false_type)
        {
-         typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
+         typedef typename std::iterator_traits<_InIterator>::iterator_category
+           _Tag;
          return _S_construct(__beg, __end, __a, _Tag());
        }
 
index e86d81011dd8094c2dd97eac30a4e2c5de9c1a7f..eacf55702c4b166998888d9d227a46e2b9c0d738 100644 (file)
@@ -98,7 +98,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         _M_construct_aux(_InIterator __beg, _InIterator __end, 
                         std::__false_type)
        {
-          typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
+          typedef typename std::iterator_traits<_InIterator>::iterator_category
+           _Tag;
           _M_construct(__beg, __end, _Tag());
        }