diff mbox series

Remove some more using-declarations from namespace __gnu_cxx

Message ID 20191030154735.GA1202@redhat.com
State New
Headers show
Series Remove some more using-declarations from namespace __gnu_cxx | expand

Commit Message

Jonathan Wakely Oct. 30, 2019, 3:47 p.m. UTC
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.

Tested powerpc64le-linux, committed to trunk.
commit 0c978d0446b42573a5201b3b5f1b6b9f42160133
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Oct 30 15:31:25 2019 +0000

    Remove some more using-declarations from namespace __gnu_cxx
    
    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.
diff mbox series

Patch

diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index 2a3b0231079..ecc06178c34 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -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;
diff --git a/libstdc++-v3/include/ext/algorithm b/libstdc++-v3/include/ext/algorithm
index 2970b7d8dfe..ec244d91860 100644
--- a/libstdc++-v3/include/ext/algorithm
+++ b/libstdc++-v3/include/ext/algorithm
@@ -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)
diff --git a/libstdc++-v3/include/ext/rc_string_base.h b/libstdc++-v3/include/ext/rc_string_base.h
index 2cf5fb0c5e3..3a902d6a18a 100644
--- a/libstdc++-v3/include/ext/rc_string_base.h
+++ b/libstdc++-v3/include/ext/rc_string_base.h
@@ -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());
 	}
 
diff --git a/libstdc++-v3/include/ext/sso_string_base.h b/libstdc++-v3/include/ext/sso_string_base.h
index e86d81011dd..eacf55702c4 100644
--- a/libstdc++-v3/include/ext/sso_string_base.h
+++ b/libstdc++-v3/include/ext/sso_string_base.h
@@ -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());
 	}