Commit 3263fb9c by Jonathan Wakely Committed by Jonathan Wakely

Remove using-declarations that add std names to __gnu_cxx

These using-declarations appear to have been added for simplicity when
moving the non-standard extensions from namespace std to namespace
__gnu_cxx. Dumping all these names into namespace __gnu_cxx allows
unportable uses like __gnu_cxx::size_t and __gnu_cxx::pair, which serve
no useful purpose.

This patch removes most of the using-declarations from namespace scope,
then either qualifies names as needed or adds using-declarations at
block scope or typedefs at class scope.

	* include/backward/hashtable.h (size_t, ptrdiff_t)
	(forward_iterator_tag, input_iterator_tag, _Construct, _Destroy)
	(distance, vector, pair, __iterator_category): Remove
	using-declarations that add these names to namespace __gnu_cxx.
	* include/ext/bitmap_allocator.h (size_t, ptrdiff_t): Likewise.
	* include/ext/debug_allocator.h (size_t): Likewise.
	* include/ext/functional (size_t, unary_function, binary_function)
	(mem_fun1_t, const_mem_fun1_t, mem_fun1_ref_t, const_mem_fun1_ref_t):
	Likewise.
	* include/ext/malloc_allocator.h (size_t, ptrdiff_t): Likewise.
	* include/ext/memory (ptrdiff_t, pair, __iterator_category): Likewise.
	* include/ext/mt_allocator.h (size_t, ptrdiff_t): Likewise.
	* include/ext/new_allocator.h (size_t, ptrdiff_t): Likewise.
	* include/ext/numeric (iota): Fix outdated comment.
	* include/ext/pool_allocator.h (size_t, ptrdiff_t): Likewise.
	* include/ext/rb_tree (_Rb_tree, allocator): Likewise.
	* include/ext/rope (size_t, ptrdiff_t, allocator, _Destroy): Likewise.
	* include/ext/ropeimpl.h (size_t, printf, basic_ostream)
	(__throw_length_error, _Destroy, std::__uninitialized_fill_n_a):
	Likewise.
	* include/ext/slist (size_t, ptrdiff_t, _Construct, _Destroy)
	(allocator, __true_type, __false_type): Likewise.

From-SVN: r271807
parent 608a080c
2019-05-31 Jonathan Wakely <jwakely@redhat.com>
* include/backward/hashtable.h (size_t, ptrdiff_t)
(forward_iterator_tag, input_iterator_tag, _Construct, _Destroy)
(distance, vector, pair, __iterator_category): Remove
using-declarations that add these names to namespace __gnu_cxx.
* include/ext/bitmap_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/debug_allocator.h (size_t): Likewise.
* include/ext/functional (size_t, unary_function, binary_function)
(mem_fun1_t, const_mem_fun1_t, mem_fun1_ref_t, const_mem_fun1_ref_t):
Likewise.
* include/ext/malloc_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/memory (ptrdiff_t, pair, __iterator_category): Likewise.
* include/ext/mt_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/new_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/numeric (iota): Fix outdated comment.
* include/ext/pool_allocator.h (size_t, ptrdiff_t): Likewise.
* include/ext/rb_tree (_Rb_tree, allocator): Likewise.
* include/ext/rope (size_t, ptrdiff_t, allocator, _Destroy): Likewise.
* include/ext/ropeimpl.h (size_t, printf, basic_ostream)
(__throw_length_error, _Destroy, std::__uninitialized_fill_n_a):
Likewise.
* include/ext/slist (size_t, ptrdiff_t, _Construct, _Destroy)
(allocator, __true_type, __false_type): Likewise.
2019-05-31 Antony Polukhin <antoshkka@gmail.com>
PR libstdc++/71579
......
......@@ -69,17 +69,6 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::ptrdiff_t;
using std::forward_iterator_tag;
using std::input_iterator_tag;
using std::_Construct;
using std::_Destroy;
using std::distance;
using std::vector;
using std::pair;
using std::__iterator_category;
template<class _Val>
struct _Hashtable_node
{
......@@ -112,10 +101,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_ExtractKey, _EqualKey, _Alloc>
const_iterator;
typedef _Hashtable_node<_Val> _Node;
typedef forward_iterator_tag iterator_category;
typedef std::forward_iterator_tag iterator_category;
typedef _Val value_type;
typedef ptrdiff_t difference_type;
typedef size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef _Val& reference;
typedef _Val* pointer;
......@@ -164,10 +153,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const_iterator;
typedef _Hashtable_node<_Val> _Node;
typedef forward_iterator_tag iterator_category;
typedef std::forward_iterator_tag iterator_category;
typedef _Val value_type;
typedef ptrdiff_t difference_type;
typedef size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef const _Val& reference;
typedef const _Val* pointer;
......@@ -272,8 +261,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef _HashFcn hasher;
typedef _EqualKey key_equal;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
......@@ -299,7 +288,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
private:
typedef typename _Alloc::template rebind<_Node>::other _Node_Alloc;
typedef typename _Alloc::template rebind<_Node*>::other _Nodeptr_Alloc;
typedef vector<_Node*, _Nodeptr_Alloc> _Vector_type;
typedef std::vector<_Node*, _Nodeptr_Alloc> _Vector_type;
_Node_Alloc _M_node_allocator;
......@@ -445,7 +434,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __result;
}
pair<iterator, bool>
std::pair<iterator, bool>
insert_unique(const value_type& __obj)
{
resize(_M_num_elements + 1);
......@@ -459,7 +448,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return insert_equal_noresize(__obj);
}
pair<iterator, bool>
std::pair<iterator, bool>
insert_unique_noresize(const value_type& __obj);
iterator
......@@ -468,17 +457,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<class _InputIterator>
void
insert_unique(_InputIterator __f, _InputIterator __l)
{ insert_unique(__f, __l, __iterator_category(__f)); }
{ insert_unique(__f, __l, std::__iterator_category(__f)); }
template<class _InputIterator>
void
insert_equal(_InputIterator __f, _InputIterator __l)
{ insert_equal(__f, __l, __iterator_category(__f)); }
{ insert_equal(__f, __l, std::__iterator_category(__f)); }
template<class _InputIterator>
void
insert_unique(_InputIterator __f, _InputIterator __l,
input_iterator_tag)
std::input_iterator_tag)
{
for ( ; __f != __l; ++__f)
insert_unique(*__f);
......@@ -487,7 +476,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<class _InputIterator>
void
insert_equal(_InputIterator __f, _InputIterator __l,
input_iterator_tag)
std::input_iterator_tag)
{
for ( ; __f != __l; ++__f)
insert_equal(*__f);
......@@ -496,9 +485,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<class _ForwardIterator>
void
insert_unique(_ForwardIterator __f, _ForwardIterator __l,
forward_iterator_tag)
std::forward_iterator_tag)
{
size_type __n = distance(__f, __l);
size_type __n = std::distance(__f, __l);
resize(_M_num_elements + __n);
for ( ; __n > 0; --__n, ++__f)
insert_unique_noresize(*__f);
......@@ -507,9 +496,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<class _ForwardIterator>
void
insert_equal(_ForwardIterator __f, _ForwardIterator __l,
forward_iterator_tag)
std::forward_iterator_tag)
{
size_type __n = distance(__f, __l);
size_type __n = std::distance(__f, __l);
resize(_M_num_elements + __n);
for ( ; __n > 0; --__n, ++__f)
insert_equal_noresize(*__f);
......@@ -555,10 +544,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __result;
}
pair<iterator, iterator>
std::pair<iterator, iterator>
equal_range(const key_type& __key);
pair<const_iterator, const_iterator>
std::pair<const_iterator, const_iterator>
equal_range(const key_type& __key) const;
size_type
......@@ -605,11 +594,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _M_bkt_num_key(_M_get_key(__obj)); }
size_type
_M_bkt_num_key(const key_type& __key, size_t __n) const
_M_bkt_num_key(const key_type& __key, std::size_t __n) const
{ return _M_hash(__key) % __n; }
size_type
_M_bkt_num(const value_type& __obj, size_t __n) const
_M_bkt_num(const value_type& __obj, std::size_t __n) const
{ return _M_bkt_num_key(_M_get_key(__obj), __n); }
_Node*
......@@ -712,7 +701,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
if (__ht1._M_buckets.size() != __ht2._M_buckets.size())
return false;
for (size_t __n = 0; __n < __ht1._M_buckets.size(); ++__n)
for (std::size_t __n = 0; __n < __ht1._M_buckets.size(); ++__n)
{
_Node* __cur1 = __ht1._M_buckets[__n];
_Node* __cur2 = __ht2._M_buckets[__n];
......@@ -757,7 +746,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ __ht1.swap(__ht2); }
template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
pair<typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator, bool>
std::pair<typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator,
bool>
hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::
insert_unique_noresize(const value_type& __obj)
{
......@@ -766,13 +756,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
for (_Node* __cur = __first; __cur; __cur = __cur->_M_next)
if (_M_equals(_M_get_key(__cur->_M_val), _M_get_key(__obj)))
return pair<iterator, bool>(iterator(__cur, this), false);
return std::pair<iterator, bool>(iterator(__cur, this), false);
_Node* __tmp = _M_new_node(__obj);
__tmp->_M_next = __first;
_M_buckets[__n] = __tmp;
++_M_num_elements;
return pair<iterator, bool>(iterator(__tmp, this), true);
return std::pair<iterator, bool>(iterator(__tmp, this), true);
}
template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
......@@ -822,12 +812,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
pair<typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator,
std::pair<typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator,
typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::iterator>
hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::
equal_range(const key_type& __key)
{
typedef pair<iterator, iterator> _Pii;
typedef std::pair<iterator, iterator> _Pii;
const size_type __n = _M_bkt_num_key(__key);
for (_Node* __first = _M_buckets[__n]; __first;
......@@ -848,12 +838,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<class _Val, class _Key, class _HF, class _Ex, class _Eq, class _All>
pair<typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::const_iterator,
std::pair<
typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::const_iterator,
typename hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::const_iterator>
hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::
equal_range(const key_type& __key) const
{
typedef pair<const_iterator, const_iterator> _Pii;
typedef std::pair<const_iterator, const_iterator> _Pii;
const size_type __n = _M_bkt_num_key(__key);
for (const _Node* __first = _M_buckets[__n]; __first;
......
......@@ -46,9 +46,6 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::ptrdiff_t;
namespace __detail
{
/** @class __mini_vector bitmap_allocator.h bitmap_allocator.h
......@@ -77,8 +74,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef _Tp* pointer;
typedef _Tp& reference;
typedef const _Tp& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef pointer iterator;
private:
......@@ -223,13 +220,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct __mv_iter_traits<_Tp*>
{
typedef _Tp value_type;
typedef ptrdiff_t difference_type;
typedef std::ptrdiff_t difference_type;
};
enum
{
bits_per_byte = 8,
bits_per_block = sizeof(size_t) * size_t(bits_per_byte)
bits_per_block = sizeof(std::size_t) * std::size_t(bits_per_byte)
};
template<typename _ForwardIterator, typename _Tp, typename _Compare>
......@@ -265,7 +262,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* passed to the function.
*/
template<typename _AddrPair>
inline size_t
inline std::size_t
__num_blocks(_AddrPair __ap)
{ return (__ap.second - __ap.first) + 1; }
......@@ -273,9 +270,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* passed to the function.
*/
template<typename _AddrPair>
inline size_t
inline std::size_t
__num_bitmaps(_AddrPair __ap)
{ return __num_blocks(__ap) / size_t(bits_per_block); }
{ return __num_blocks(__ap) / std::size_t(bits_per_block); }
// _Tp should be a pointer type.
template<typename _Tp>
......@@ -336,7 +333,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef typename __detail::__mini_vector<_Block_pair> _BPVector;
typedef typename _BPVector::difference_type _Counter_type;
size_t* _M_pbitmap;
std::size_t* _M_pbitmap;
_Counter_type _M_data_offset;
public:
......@@ -346,6 +343,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bool
operator()(_Block_pair __bp) throw()
{
using std::size_t;
// Set the _rover to the last physical location bitmap,
// which is the bitmap which belongs to the first free
// block. Thus, the bitmaps are in exact reverse order of
......@@ -377,13 +375,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return false;
}
size_t*
std::size_t*
_M_get() const throw()
{ return _M_pbitmap; }
_Counter_type
_M_offset() const throw()
{ return _M_data_offset * size_t(bits_per_block); }
{ return _M_data_offset * std::size_t(bits_per_block); }
};
/** @class _Bitmap_counter bitmap_allocator.h bitmap_allocator.h
......@@ -402,8 +400,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef _Tp pointer;
_BPVector& _M_vbp;
size_t* _M_curr_bmap;
size_t* _M_last_bmap_in_block;
std::size_t* _M_curr_bmap;
std::size_t* _M_last_bmap_in_block;
_Index_type _M_curr_index;
public:
......@@ -424,7 +422,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
_M_curr_index = __index;
_M_curr_bmap = reinterpret_cast<size_t*>
_M_curr_bmap = reinterpret_cast<std::size_t*>
(_M_vbp[_M_curr_index].first) - 1;
_GLIBCXX_DEBUG_ASSERT(__index <= (long)_M_vbp.size() - 1);
......@@ -432,14 +430,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_last_bmap_in_block = _M_curr_bmap
- ((_M_vbp[_M_curr_index].second
- _M_vbp[_M_curr_index].first + 1)
/ size_t(bits_per_block) - 1);
/ std::size_t(bits_per_block) - 1);
}
// Dangerous Function! Use with extreme care. Pass to this
// function ONLY those values that are known to be correct,
// otherwise this will mess up big time.
void
_M_set_internal_bitmap(size_t* __new_internal_marker) throw()
_M_set_internal_bitmap(std::size_t* __new_internal_marker) throw()
{ _M_curr_bmap = __new_internal_marker; }
bool
......@@ -461,7 +459,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return *this;
}
size_t*
std::size_t*
_M_get() const throw()
{ return _M_curr_bmap; }
......@@ -472,8 +470,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Index_type
_M_offset() const throw()
{
return size_t(bits_per_block)
* ((reinterpret_cast<size_t*>(this->_M_base())
return std::size_t(bits_per_block)
* ((reinterpret_cast<std::size_t*>(this->_M_base())
- _M_curr_bmap) - 1);
}
......@@ -486,9 +484,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* corresponding bit in the bit-map.
*/
inline void
__bit_allocate(size_t* __pbmap, size_t __pos) throw()
__bit_allocate(std::size_t* __pbmap, std::size_t __pos) throw()
{
size_t __mask = 1 << __pos;
std::size_t __mask = 1 << __pos;
__mask = ~__mask;
*__pbmap &= __mask;
}
......@@ -497,18 +495,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* corresponding bit in the bit-map.
*/
inline void
__bit_free(size_t* __pbmap, size_t __pos) throw()
__bit_free(std::size_t* __pbmap, std::size_t __pos) throw()
{
size_t __mask = 1 << __pos;
std::size_t __mask = 1 << __pos;
*__pbmap |= __mask;
}
} // namespace __detail
/** @brief Generic Version of the bsf instruction.
*/
inline size_t
_Bit_scan_forward(size_t __num)
{ return static_cast<size_t>(__builtin_ctzl(__num)); }
inline std::size_t
_Bit_scan_forward(std::size_t __num)
{ return static_cast<std::size_t>(__builtin_ctzl(__num)); }
/** @class free_list bitmap_allocator.h bitmap_allocator.h
*
......@@ -518,7 +516,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class free_list
{
public:
typedef size_t* value_type;
typedef std::size_t* value_type;
typedef __detail::__mini_vector<value_type> vector_type;
typedef vector_type::iterator iterator;
typedef __mutex __mutex_type;
......@@ -527,8 +525,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct _LT_pointer_compare
{
bool
operator()(const size_t* __pui,
const size_t __cui) const throw()
operator()(const std::size_t* __pui,
const std::size_t __cui) const throw()
{ return *__pui < __cui; }
};
......@@ -559,7 +557,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* or larger blocks from the free list.
*/
void
_M_validate(size_t* __addr) throw()
_M_validate(std::size_t* __addr) throw()
{
vector_type& __free_list = _M_get_free_list();
const vector_type::size_type __max_size = 64;
......@@ -605,10 +603,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* false.
*/
bool
_M_should_i_give(size_t __block_size,
size_t __required_size) throw()
_M_should_i_give(std::size_t __block_size,
std::size_t __required_size) throw()
{
const size_t __max_wastage_percentage = 36;
const std::size_t __max_wastage_percentage = 36;
if (__block_size >= __required_size &&
(((__block_size - __required_size) * 100 / __block_size)
< __max_wastage_percentage))
......@@ -625,14 +623,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* by a call to the _M_get function.
*/
inline void
_M_insert(size_t* __addr) throw()
_M_insert(std::size_t* __addr) throw()
{
#if defined __GTHREADS
__scoped_lock __bfl_lock(_M_get_mutex());
#endif
// Call _M_validate to decide what should be done with
// this particular free list.
this->_M_validate(reinterpret_cast<size_t*>(__addr) - 1);
this->_M_validate(reinterpret_cast<std::size_t*>(__addr) - 1);
// See discussion as to why this is 1!
}
......@@ -644,8 +642,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @return A pointer to the new memory block of size at least
* equal to that requested.
*/
size_t*
_M_get(size_t __sz) _GLIBCXX_THROW(std::bad_alloc);
std::size_t*
_M_get(std::size_t __sz) _GLIBCXX_THROW(std::bad_alloc);
/** @brief This function just clears the internal Free List, and
* gives back all the memory to the OS.
......@@ -684,8 +682,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class bitmap_allocator : private free_list
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
......@@ -706,7 +704,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
private:
template<size_t _BSize, size_t _AlignSize>
template<std::size_t _BSize, std::size_t _AlignSize>
struct aligned_size
{
enum
......@@ -765,6 +763,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
_S_refill_pool() _GLIBCXX_THROW(std::bad_alloc)
{
using std::size_t;
#if defined _GLIBCXX_DEBUG
_S_check_for_free_blocks();
#endif
......@@ -798,7 +797,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
static _BPVector _S_mem_blocks;
static size_t _S_block_size;
static std::size_t _S_block_size;
static __detail::_Bitmap_counter<_Alloc_block*> _S_last_request;
static typename _BPVector::size_type _S_last_dealloc_index;
#if defined __GTHREADS
......@@ -823,6 +822,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
pointer
_M_allocate_single_object() _GLIBCXX_THROW(std::bad_alloc)
{
using std::size_t;
#if defined __GTHREADS
__scoped_lock __bit_lock(_S_mut);
#endif
......@@ -913,6 +913,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
_M_deallocate_single_object(pointer __p) throw()
{
using std::size_t;
#if defined __GTHREADS
__scoped_lock __bit_lock(_S_mut);
#endif
......@@ -1109,8 +1110,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
bitmap_allocator<_Tp>::_S_mem_blocks;
template<typename _Tp>
size_t bitmap_allocator<_Tp>::_S_block_size =
2 * size_t(__detail::bits_per_block);
std::size_t bitmap_allocator<_Tp>::_S_block_size
= 2 * std::size_t(__detail::bits_per_block);
template<typename _Tp>
typename bitmap_allocator<_Tp>::_BPVector::size_type
......
......@@ -50,8 +50,6 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
/**
* @brief A meta-allocator with debugging bits.
* @ingroup allocators
......@@ -103,7 +101,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
size_type _S_extra()
{
const size_t __obj_size = sizeof(value_type);
const std::size_t __obj_size = sizeof(value_type);
return (sizeof(size_type) + __obj_size - 1) / __obj_size;
}
......
......@@ -64,14 +64,6 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::unary_function;
using std::binary_function;
using std::mem_fun1_t;
using std::const_mem_fun1_t;
using std::mem_fun1_ref_t;
using std::const_mem_fun1_ref_t;
/** The @c identity_element functions are not part of the C++
* standard; SGI provided them as an extension. Its argument is an
* operation, and its return value is the identity element for that
......@@ -123,7 +115,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// An \link SGIextensions SGI extension \endlink.
template <class _Operation1, class _Operation2>
class unary_compose
: public unary_function<typename _Operation2::argument_type,
: public std::unary_function<typename _Operation2::argument_type,
typename _Operation1::result_type>
{
protected:
......@@ -148,7 +140,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// An \link SGIextensions SGI extension \endlink.
template <class _Operation1, class _Operation2, class _Operation3>
class binary_compose
: public unary_function<typename _Operation2::argument_type,
: public std::unary_function<typename _Operation2::argument_type,
typename _Operation1::result_type>
{
protected:
......@@ -209,7 +201,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// extension documented next
template <class _Arg1, class _Arg2>
struct _Project1st : public binary_function<_Arg1, _Arg2, _Arg1>
struct _Project1st : public std::binary_function<_Arg1, _Arg2, _Arg1>
{
_Arg1
operator()(const _Arg1& __x, const _Arg2&) const
......@@ -217,7 +209,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
};
template <class _Arg1, class _Arg2>
struct _Project2nd : public binary_function<_Arg1, _Arg2, _Arg2>
struct _Project2nd : public std::binary_function<_Arg1, _Arg2, _Arg2>
{
_Arg2
operator()(const _Arg1&, const _Arg2& __y) const
......@@ -350,12 +342,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @ingroup SGIextensions
*/
class subtractive_rng
: public unary_function<unsigned int, unsigned int>
: public std::unary_function<unsigned int, unsigned int>
{
private:
unsigned int _M_table[55];
size_t _M_index1;
size_t _M_index2;
std::size_t _M_index1;
std::size_t _M_index2;
public:
/// Returns a number less than the argument.
......@@ -373,10 +365,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
unsigned int __k = 1;
_M_table[54] = __seed;
size_t __i;
std::size_t __i;
for (__i = 0; __i < 54; __i++)
{
size_t __ii = (21 * (__i + 1) % 55) - 1;
std::size_t __ii = (21 * (__i + 1) % 55) - 1;
_M_table[__ii] = __k;
__k = __seed - __k;
__seed = _M_table[__ii];
......@@ -404,24 +396,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// the C++ standard.
template <class _Ret, class _Tp, class _Arg>
inline mem_fun1_t<_Ret, _Tp, _Arg>
inline std::mem_fun1_t<_Ret, _Tp, _Arg>
mem_fun1(_Ret (_Tp::*__f)(_Arg))
{ return mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
{ return std::mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
template <class _Ret, class _Tp, class _Arg>
inline const_mem_fun1_t<_Ret, _Tp, _Arg>
inline std::const_mem_fun1_t<_Ret, _Tp, _Arg>
mem_fun1(_Ret (_Tp::*__f)(_Arg) const)
{ return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
{ return std::const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
template <class _Ret, class _Tp, class _Arg>
inline mem_fun1_ref_t<_Ret, _Tp, _Arg>
inline std::mem_fun1_ref_t<_Ret, _Tp, _Arg>
mem_fun1_ref(_Ret (_Tp::*__f)(_Arg))
{ return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
{ return std::mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
template <class _Ret, class _Tp, class _Arg>
inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
inline std::const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
mem_fun1_ref(_Ret (_Tp::*__f)(_Arg) const)
{ return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
{ return std::const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
......
......@@ -42,9 +42,6 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::ptrdiff_t;
/**
* @brief An allocator that uses malloc.
* @ingroup allocators
......@@ -57,8 +54,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class malloc_allocator
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
......@@ -141,9 +138,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
max_size() const _GLIBCXX_USE_NOEXCEPT
{
#if __PTRDIFF_MAX__ < __SIZE_MAX__
return size_t(__PTRDIFF_MAX__) / sizeof(_Tp);
return std::size_t(__PTRDIFF_MAX__) / sizeof(_Tp);
#else
return size_t(-1) / sizeof(_Tp);
return std::size_t(-1) / sizeof(_Tp);
#endif
}
......
......@@ -65,13 +65,10 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::ptrdiff_t;
using std::pair;
using std::__iterator_category;
using std::_Temporary_buffer;
template<typename _InputIter, typename _Size, typename _ForwardIter>
pair<_InputIter, _ForwardIter>
std::pair<_InputIter, _ForwardIter>
__uninitialized_copy_n(_InputIter __first, _Size __count,
_ForwardIter __result, std::input_iterator_tag)
{
......@@ -80,7 +77,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
for (; __count > 0 ; --__count, ++__first, ++__cur)
std::_Construct(&*__cur, *__first);
return pair<_InputIter, _ForwardIter>(__first, __cur);
return std::pair<_InputIter, _ForwardIter>(__first, __cur);
}
__catch(...)
{
......@@ -90,22 +87,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
template<typename _RandomAccessIter, typename _Size, typename _ForwardIter>
inline pair<_RandomAccessIter, _ForwardIter>
inline std::pair<_RandomAccessIter, _ForwardIter>
__uninitialized_copy_n(_RandomAccessIter __first, _Size __count,
_ForwardIter __result,
std::random_access_iterator_tag)
{
_RandomAccessIter __last = __first + __count;
return (pair<_RandomAccessIter, _ForwardIter>
return (std::pair<_RandomAccessIter, _ForwardIter>
(__last, std::uninitialized_copy(__first, __last, __result)));
}
template<typename _InputIter, typename _Size, typename _ForwardIter>
inline pair<_InputIter, _ForwardIter>
inline std::pair<_InputIter, _ForwardIter>
__uninitialized_copy_n(_InputIter __first, _Size __count,
_ForwardIter __result)
{ return __gnu_cxx::__uninitialized_copy_n(__first, __count, __result,
__iterator_category(__first)); }
{
return __gnu_cxx::__uninitialized_copy_n(__first, __count, __result,
std::__iterator_category(__first));
}
/**
* @brief Copies the range [first,last) into result.
......@@ -118,18 +117,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* Like copy(), but does not require an initialized output range.
*/
template<typename _InputIter, typename _Size, typename _ForwardIter>
inline pair<_InputIter, _ForwardIter>
inline std::pair<_InputIter, _ForwardIter>
uninitialized_copy_n(_InputIter __first, _Size __count,
_ForwardIter __result)
{ return __gnu_cxx::__uninitialized_copy_n(__first, __count, __result,
__iterator_category(__first)); }
{
return __gnu_cxx::__uninitialized_copy_n(__first, __count, __result,
std::__iterator_category(__first));
}
// An alternative version of uninitialized_copy_n that constructs
// and destroys objects with a user-provided allocator.
template<typename _InputIter, typename _Size, typename _ForwardIter,
typename _Allocator>
pair<_InputIter, _ForwardIter>
std::pair<_InputIter, _ForwardIter>
__uninitialized_copy_n_a(_InputIter __first, _Size __count,
_ForwardIter __result,
_Allocator __alloc)
......@@ -139,7 +140,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
for (; __count > 0 ; --__count, ++__first, ++__cur)
__alloc.construct(&*__cur, *__first);
return pair<_InputIter, _ForwardIter>(__first, __cur);
return std::pair<_InputIter, _ForwardIter>(__first, __cur);
}
__catch(...)
{
......@@ -150,7 +151,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _InputIter, typename _Size, typename _ForwardIter,
typename _Tp>
inline pair<_InputIter, _ForwardIter>
inline std::pair<_InputIter, _ForwardIter>
__uninitialized_copy_n_a(_InputIter __first, _Size __count,
_ForwardIter __result,
std::allocator<_Tp>)
......
......@@ -42,8 +42,6 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::ptrdiff_t;
typedef void (*__destroy_handler)(void*);
......@@ -53,6 +51,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Using short int as type for the binmap implies we are never
// caching blocks larger than 32768 with this allocator.
typedef unsigned short int _Binmap_type;
typedef std::size_t size_t;
// Variables used to configure the behavior of the allocator,
// assigned and explained in detail below.
......@@ -478,6 +477,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static pool_type&
_S_get_pool()
{
using std::size_t;
// Sane defaults for the _PoolTp.
typedef typename pool_type::_Block_record _Block_record;
const static size_t __a = (__alignof__(_Tp) >= sizeof(_Block_record)
......@@ -570,8 +570,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class __mt_alloc_base
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
......@@ -594,7 +594,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
size_type
max_size() const _GLIBCXX_USE_NOEXCEPT
{ return size_t(-1) / sizeof(_Tp); }
{ return size_type(-1) / sizeof(_Tp); }
#if __cplusplus >= 201103L
template<typename _Up, typename... _Args>
......@@ -639,8 +639,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class __mt_alloc : public __mt_alloc_base<_Tp>
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
......@@ -705,7 +705,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Requests larger than _M_max_bytes are handled by operator
// new/delete directly.
__pool_type& __pool = __policy_type::_S_get_pool();
const size_t __bytes = __n * sizeof(_Tp);
const size_type __bytes = __n * sizeof(_Tp);
if (__pool._M_check_threshold(__bytes))
{
void* __ret = ::operator new(__bytes);
......@@ -713,8 +713,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
// Round up to power of 2 and figure out which bin to use.
const size_t __which = __pool._M_get_binmap(__bytes);
const size_t __thread_id = __pool._M_get_thread_id();
const size_type __which = __pool._M_get_binmap(__bytes);
const size_type __thread_id = __pool._M_get_thread_id();
// Find out if we have blocks on our freelist. If so, go ahead
// and use them directly without having to lock anything.
......@@ -758,7 +758,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Requests larger than _M_max_bytes are handled by
// operators new/delete directly.
__pool_type& __pool = __policy_type::_S_get_pool();
const size_t __bytes = __n * sizeof(_Tp);
const size_type __bytes = __n * sizeof(_Tp);
if (__pool._M_check_threshold(__bytes))
::operator delete(__p);
else
......
......@@ -41,9 +41,6 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::ptrdiff_t;
/**
* @brief An allocator that uses global new, as per [20.4].
* @ingroup allocators
......@@ -58,8 +55,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
class new_allocator
{
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
......@@ -140,9 +137,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
max_size() const _GLIBCXX_USE_NOEXCEPT
{
#if __PTRDIFF_MAX__ < __SIZE_MAX__
return size_t(__PTRDIFF_MAX__) / sizeof(_Tp);
return std::size_t(__PTRDIFF_MAX__) / sizeof(_Tp);
#else
return size_t(-1) / sizeof(_Tp);
return std::size_t(-1) / sizeof(_Tp);
#endif
}
......
......@@ -131,7 +131,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @ingroup SGIextensions
* @doctodo
*/
// iota is not part of the C++ standard. It is an extension.
// iota is not part of the standard until C++11. It is an extension.
template<typename _ForwardIter, typename _Tp>
void
iota(_ForwardIter __first, _ForwardIter __last, _Tp __value)
......
......@@ -57,9 +57,6 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::ptrdiff_t;
/**
* @brief Base class for __pool_alloc.
*
......@@ -77,6 +74,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
class __pool_alloc_base
{
typedef std::size_t size_t;
protected:
enum { _S_align = 8 };
......@@ -129,8 +127,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static _Atomic_word _S_force_new;
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef _Tp* pointer;
typedef const _Tp* const_pointer;
typedef _Tp& reference;
......@@ -166,7 +164,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
size_type
max_size() const _GLIBCXX_USE_NOEXCEPT
{ return size_t(-1) / sizeof(_Tp); }
{ return std::size_t(-1) / sizeof(_Tp); }
#if __cplusplus >= 201103L
template<typename _Up, typename... _Args>
......@@ -213,6 +211,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_NODISCARD _Tp*
__pool_alloc<_Tp>::allocate(size_type __n, const void*)
{
using std::size_t;
pointer __ret = 0;
if (__builtin_expect(__n != 0, true))
{
......@@ -266,6 +265,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
__pool_alloc<_Tp>::deallocate(pointer __p, size_type __n)
{
using std::size_t;
if (__builtin_expect(__n != 0 && __p != 0, true))
{
#if __cpp_aligned_new
......
......@@ -64,9 +64,6 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::_Rb_tree;
using std::allocator;
// Class rb_tree is not part of the C++ standard. It is provided for
// compatibility with the HP STL.
......@@ -76,11 +73,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @doctodo
*/
template <class _Key, class _Value, class _KeyOfValue, class _Compare,
class _Alloc = allocator<_Value> >
class _Alloc = std::allocator<_Value> >
struct rb_tree
: public _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc>
: public std::_Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc>
{
typedef _Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> _Base;
typedef std::_Rb_tree<_Key, _Value, _KeyOfValue, _Compare, _Alloc> _Base;
typedef typename _Base::allocator_type allocator_type;
rb_tree(const _Compare& __comp = _Compare(),
......
......@@ -54,14 +54,6 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
using std::size_t;
using std::ptrdiff_t;
using std::_Construct;
using std::_Destroy;
using std::allocator;
using std::__true_type;
using std::__false_type;
struct _Slist_node_base
{
_Slist_node_base* _M_next;
......@@ -138,10 +130,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return __result;
}
inline size_t
inline std::size_t
__slist_size(_Slist_node_base* __node)
{
size_t __result = 0;
std::size_t __result = 0;
for (; __node != 0; __node = __node->_M_next)
++__result;
return __result;
......@@ -155,8 +147,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct _Slist_iterator_base
{
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef std::forward_iterator_tag iterator_category;
_Slist_node_base* _M_node;
......@@ -288,7 +280,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @ingroup SGIextensions
* @doctodo
*/
template <class _Tp, class _Alloc = allocator<_Tp> >
template <class _Tp, class _Alloc = std::allocator<_Tp> >
class slist : private _Slist_base<_Tp,_Alloc>
{
// concept requirements
......@@ -303,8 +295,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
typedef _Slist_iterator<_Tp, _Tp&, _Tp*> iterator;
typedef _Slist_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;
......@@ -409,13 +401,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template <class _Integer>
void
_M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
_M_assign_dispatch(_Integer __n, _Integer __val, std::__true_type)
{ _M_fill_assign((size_type) __n, (_Tp) __val); }
template <class _InputIterator>
void
_M_assign_dispatch(_InputIterator __first, _InputIterator __last,
__false_type);
std::__false_type);
public:
......@@ -533,14 +525,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template <class _Integer>
void
_M_insert_after_range(_Node_base* __pos, _Integer __n, _Integer __x,
__true_type)
std::__true_type)
{ _M_insert_after_fill(__pos, __n, __x); }
template <class _InIterator>
void
_M_insert_after_range(_Node_base* __pos,
_InIterator __first, _InIterator __last,
__false_type)
std::__false_type)
{
while (__first != __last)
{
......@@ -771,7 +763,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
slist<_Tp, _Alloc>::_M_assign_dispatch(_InputIterator __first,
_InputIterator __last,
__false_type)
std::__false_type)
{
_Node_base* __prev = &this->_M_head;
_Node* __node = (_Node*) this->_M_head._M_next;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment