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.

From-SVN: r277630
This commit is contained in:
Jonathan Wakely 2019-10-30 15:48:23 +00:00 committed by Jonathan Wakely
parent 9aeb3bef2c
commit d03eca30d7
5 changed files with 40 additions and 37 deletions

View File

@ -1,5 +1,15 @@
2019-10-30 Jonathan Wakely <jwakely@redhat.com> 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 PR libstdc++/92272
* include/bits/stl_bvector.h (_Bit_iterator::pointer) * include/bits/stl_bvector.h (_Bit_iterator::pointer)
(_Bit_const_iterator::pointer): Define as void for C++20. (_Bit_const_iterator::pointer): Define as void for C++20.

View File

@ -793,15 +793,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// The _Container parameter exists solely so that different containers // The _Container parameter exists solely so that different containers
// using this template can instantiate different types, even if the // using this template can instantiate different types, even if the
// _Iterator parameter is the same. // _Iterator parameter is the same.
using std::iterator_traits;
using std::iterator;
template<typename _Iterator, typename _Container> template<typename _Iterator, typename _Container>
class __normal_iterator class __normal_iterator
{ {
protected: protected:
_Iterator _M_current; _Iterator _M_current;
typedef iterator_traits<_Iterator> __traits_type; typedef std::iterator_traits<_Iterator> __traits_type;
public: public:
typedef _Iterator iterator_type; typedef _Iterator iterator_type;

View File

@ -64,21 +64,14 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _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) // copy_n (not part of the C++ standard)
template<typename _InputIterator, typename _Size, typename _OutputIterator> template<typename _InputIterator, typename _Size, typename _OutputIterator>
pair<_InputIterator, _OutputIterator> std::pair<_InputIterator, _OutputIterator>
__copy_n(_InputIterator __first, _Size __count, __copy_n(_InputIterator __first, _Size __count,
_OutputIterator __result, _OutputIterator __result,
input_iterator_tag) std::input_iterator_tag)
{ {
for ( ; __count > 0; --__count) for ( ; __count > 0; --__count)
{ {
@ -86,17 +79,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
++__first; ++__first;
++__result; ++__result;
} }
return pair<_InputIterator, _OutputIterator>(__first, __result); return std::pair<_InputIterator, _OutputIterator>(__first, __result);
} }
template<typename _RAIterator, typename _Size, typename _OutputIterator> template<typename _RAIterator, typename _Size, typename _OutputIterator>
inline pair<_RAIterator, _OutputIterator> inline std::pair<_RAIterator, _OutputIterator>
__copy_n(_RAIterator __first, _Size __count, __copy_n(_RAIterator __first, _Size __count,
_OutputIterator __result, _OutputIterator __result,
random_access_iterator_tag) std::random_access_iterator_tag)
{ {
_RAIterator __last = __first + __count; _RAIterator __last = __first + __count;
return pair<_RAIterator, _OutputIterator>(__last, std::copy(__first, return std::pair<_RAIterator, _OutputIterator>(__last, std::copy(__first,
__last, __last,
__result)); __result));
} }
@ -116,13 +109,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @ingroup SGIextensions * @ingroup SGIextensions
*/ */
template<typename _InputIterator, typename _Size, typename _OutputIterator> template<typename _InputIterator, typename _Size, typename _OutputIterator>
inline pair<_InputIterator, _OutputIterator> inline std::pair<_InputIterator, _OutputIterator>
copy_n(_InputIterator __first, _Size __count, _OutputIterator __result) copy_n(_InputIterator __first, _Size __count, _OutputIterator __result)
{ {
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, __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, return __gnu_cxx::__copy_n(__first, __count, __result,
std::__iterator_category(__first)); std::__iterator_category(__first));
@ -156,10 +149,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const unsigned char* __first2, const unsigned char* __first2,
const unsigned char* __last2) const unsigned char* __last2)
{ {
const ptrdiff_t __len1 = __last1 - __first1; const std::ptrdiff_t __len1 = __last1 - __first1;
const ptrdiff_t __len2 = __last2 - __first2; const std::ptrdiff_t __len2 = __last2 - __first2;
const int __result = __builtin_memcmp(__first1, __first2, const int __result = __builtin_memcmp(__first1, __first2,
min(__len1, __len2)); (std::min)(__len1, __len2));
return __result != 0 ? __result return __result != 0 ? __result
: (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1)); : (__len1 == __len2 ? 0 : (__len1 < __len2 ? -1 : 1));
} }
@ -207,9 +200,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_function_requires(_LessThanComparableConcept< __glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_InputIterator1>::value_type>) typename std::iterator_traits<_InputIterator1>::value_type>)
__glibcxx_function_requires(_LessThanComparableConcept< __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(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2); __glibcxx_requires_valid_range(__first2, __last2);
@ -228,7 +221,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_EqualityComparableConcept< __glibcxx_function_requires(_EqualityComparableConcept<
typename iterator_traits<_InputIterator>::value_type >) typename std::iterator_traits<_InputIterator>::value_type >)
__glibcxx_function_requires(_EqualityComparableConcept<_Tp>) __glibcxx_function_requires(_EqualityComparableConcept<_Tp>)
__glibcxx_requires_valid_range(__first, __last); __glibcxx_requires_valid_range(__first, __last);
@ -246,7 +239,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// concept requirements // concept requirements
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
__glibcxx_function_requires(_UnaryPredicateConcept<_Predicate, __glibcxx_function_requires(_UnaryPredicateConcept<_Predicate,
typename iterator_traits<_InputIterator>::value_type>) typename std::iterator_traits<_InputIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last); __glibcxx_requires_valid_range(__first, __last);
for ( ; __first != __last; ++__first) for ( ; __first != __last; ++__first)
@ -270,11 +263,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// concept requirements // concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_ForwardIterator>::value_type>) typename std::iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last); __glibcxx_requires_valid_range(__first, __last);
_Distance __remaining = std::distance(__first, __last); _Distance __remaining = std::distance(__first, __last);
_Distance __m = min(__n, __remaining); _Distance __m = (std::min)(__n, __remaining);
while (__m > 0) while (__m > 0)
{ {
@ -305,13 +298,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// concept requirements // concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator, __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
typename iterator_traits<_ForwardIterator>::value_type>) typename std::iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_function_requires(_UnaryFunctionConcept< __glibcxx_function_requires(_UnaryFunctionConcept<
_RandomNumberGenerator, _Distance, _Distance>) _RandomNumberGenerator, _Distance, _Distance>)
__glibcxx_requires_valid_range(__first, __last); __glibcxx_requires_valid_range(__first, __last);
_Distance __remaining = std::distance(__first, __last); _Distance __remaining = std::distance(__first, __last);
_Distance __m = min(__n, __remaining); _Distance __m = (std::min)(__n, __remaining);
while (__m > 0) while (__m > 0)
{ {
@ -441,7 +434,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__glibcxx_function_requires(_RandomAccessIteratorConcept< __glibcxx_function_requires(_RandomAccessIteratorConcept<
_RandomAccessIterator>) _RandomAccessIterator>)
__glibcxx_function_requires(_LessThanComparableConcept< __glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_RandomAccessIterator>::value_type>) typename std::iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last); __glibcxx_requires_valid_range(__first, __last);
return std::__is_heap(__first, __last - __first); return std::__is_heap(__first, __last - __first);
@ -461,8 +454,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__glibcxx_function_requires(_RandomAccessIteratorConcept< __glibcxx_function_requires(_RandomAccessIteratorConcept<
_RandomAccessIterator>) _RandomAccessIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering, __glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering,
typename iterator_traits<_RandomAccessIterator>::value_type, typename std::iterator_traits<_RandomAccessIterator>::value_type,
typename iterator_traits<_RandomAccessIterator>::value_type>) typename std::iterator_traits<_RandomAccessIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last); __glibcxx_requires_valid_range(__first, __last);
return std::__is_heap(__first, __comp, __last - __first); return std::__is_heap(__first, __comp, __last - __first);
@ -488,7 +481,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// concept requirements // concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_LessThanComparableConcept< __glibcxx_function_requires(_LessThanComparableConcept<
typename iterator_traits<_ForwardIterator>::value_type>) typename std::iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last); __glibcxx_requires_valid_range(__first, __last);
if (__first == __last) if (__first == __last)
@ -514,8 +507,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// concept requirements // concept requirements
__glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>) __glibcxx_function_requires(_ForwardIteratorConcept<_ForwardIterator>)
__glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering, __glibcxx_function_requires(_BinaryPredicateConcept<_StrictWeakOrdering,
typename iterator_traits<_ForwardIterator>::value_type, typename std::iterator_traits<_ForwardIterator>::value_type,
typename iterator_traits<_ForwardIterator>::value_type>) typename std::iterator_traits<_ForwardIterator>::value_type>)
__glibcxx_requires_valid_range(__first, __last); __glibcxx_requires_valid_range(__first, __last);
if (__first == __last) if (__first == __last)

View File

@ -231,7 +231,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_S_construct_aux(_InIterator __beg, _InIterator __end, _S_construct_aux(_InIterator __beg, _InIterator __end,
const _Alloc& __a, std::__false_type) 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()); return _S_construct(__beg, __end, __a, _Tag());
} }

View File

@ -98,7 +98,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_construct_aux(_InIterator __beg, _InIterator __end, _M_construct_aux(_InIterator __beg, _InIterator __end,
std::__false_type) 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()); _M_construct(__beg, __end, _Tag());
} }