(this->_M_impl._M_header._M_parent);
}
- _Link_type
+ _Base_ptr
_M_end() _GLIBCXX_NOEXCEPT
- { return reinterpret_cast<_Link_type>(&this->_M_impl._M_header); }
+ { return &this->_M_impl._M_header; }
- _Const_Link_type
+ _Const_Base_ptr
_M_end() const _GLIBCXX_NOEXCEPT
- { return reinterpret_cast<_Const_Link_type>(&this->_M_impl._M_header); }
+ { return &this->_M_impl._M_header; }
static const_reference
_S_value(_Const_Link_type __x)
template<typename _NodeGen>
_Link_type
- _M_copy(_Const_Link_type __x, _Link_type __p, _NodeGen&);
+ _M_copy(_Const_Link_type __x, _Base_ptr __p, _NodeGen&);
_Link_type
- _M_copy(_Const_Link_type __x, _Link_type __p)
+ _M_copy(_Const_Link_type __x, _Base_ptr __p)
{
_Alloc_node __an(*this);
return _M_copy(__x, __p, __an);
_M_erase(_Link_type __x);
iterator
- _M_lower_bound(_Link_type __x, _Link_type __y,
+ _M_lower_bound(_Link_type __x, _Base_ptr __y,
const _Key& __k);
const_iterator
- _M_lower_bound(_Const_Link_type __x, _Const_Link_type __y,
+ _M_lower_bound(_Const_Link_type __x, _Const_Base_ptr __y,
const _Key& __k) const;
iterator
- _M_upper_bound(_Link_type __x, _Link_type __y,
+ _M_upper_bound(_Link_type __x, _Base_ptr __y,
const _Key& __k);
const_iterator
- _M_upper_bound(_Const_Link_type __x, _Const_Link_type __y,
+ _M_upper_bound(_Const_Link_type __x, _Const_Base_ptr __y,
const _Key& __k) const;
public:
__is_transparent<_Cmp, _Kt, __void_t<typename _Cmp::is_transparent>>
{ typedef void type; };
- static auto _S_iter(_Link_type __x) { return iterator(__x); }
-
- static auto _S_iter(_Const_Link_type __x) { return const_iterator(__x); }
-
- template<typename _Cmp, typename _Link, typename _Kt>
- static auto
- _S_lower_bound_tr(_Cmp& __cmp, _Link __x, _Link __y, const _Kt& __k)
- {
- while (__x != 0)
- if (!__cmp(_S_key(__x), __k))
- __y = __x, __x = _S_left(__x);
- else
- __x = _S_right(__x);
- return _S_iter(__y);
- }
-
- template<typename _Cmp, typename _Link, typename _Kt>
- static auto
- _S_upper_bound_tr(_Cmp& __cmp, _Link __x, _Link __y, const _Kt& __k)
- {
- while (__x != 0)
- if (__cmp(__k, _S_key(__x)))
- __y = __x, __x = _S_left(__x);
- else
- __x = _S_right(__x);
- return _S_iter(__y);
- }
-
template<typename _Kt,
typename _Req = typename __is_transparent<_Compare, _Kt>::type>
iterator
_M_find_tr(const _Kt& __k)
{
- auto& __cmp = _M_impl._M_key_compare;
- auto __j = _S_lower_bound_tr(__cmp, _M_begin(), _M_end(), __k);
- return (__j == end() || __cmp(__k, _S_key(__j._M_node)))
- ? end() : __j;
+ const _Rb_tree* __const_this = this;
+ return __const_this->_M_find_tr(__k)._M_const_cast();
}
template<typename _Kt,
const_iterator
_M_find_tr(const _Kt& __k) const
{
- auto& __cmp = _M_impl._M_key_compare;
- auto __j = _S_lower_bound_tr(__cmp, _M_begin(), _M_end(), __k);
- return (__j == end() || __cmp(__k, _S_key(__j._M_node)))
- ? end() : __j;
+ auto __j = _M_lower_bound_tr(__k);
+ if (__j != end() && _M_impl._M_key_compare(__k, _S_key(__j._M_node)))
+ __j = end();
+ return __j;
}
template<typename _Kt,
iterator
_M_lower_bound_tr(const _Kt& __k)
{
- auto& __cmp = _M_impl._M_key_compare;
- return _S_lower_bound_tr(__cmp, _M_begin(), _M_end(), __k);
+ const _Rb_tree* __const_this = this;
+ return __const_this->_M_lower_bound_tr(__k)._M_const_cast();
}
template<typename _Kt,
const_iterator
_M_lower_bound_tr(const _Kt& __k) const
{
- auto& __cmp = _M_impl._M_key_compare;
- return _S_lower_bound_tr(__cmp, _M_begin(), _M_end(), __k);
+ auto __x = _M_begin();
+ auto __y = _M_end();
+ while (__x != 0)
+ if (!_M_impl._M_key_compare(_S_key(__x), __k))
+ {
+ __y = __x;
+ __x = _S_left(__x);
+ }
+ else
+ __x = _S_right(__x);
+ return const_iterator(__y);
}
template<typename _Kt,
iterator
_M_upper_bound_tr(const _Kt& __k)
{
- auto& __cmp = _M_impl._M_key_compare;
- return _S_upper_bound_tr(__cmp, _M_begin(), _M_end(), __k);
+ const _Rb_tree* __const_this = this;
+ return __const_this->_M_upper_bound_tr(__k)._M_const_cast();
}
template<typename _Kt,
const_iterator
_M_upper_bound_tr(const _Kt& __k) const
{
- auto& __cmp = _M_impl._M_key_compare;
- return _S_upper_bound_tr(__cmp, _M_begin(), _M_end(), __k);
+ auto __x = _M_begin();
+ auto __y = _M_end();
+ while (__x != 0)
+ if (_M_impl._M_key_compare(__k, _S_key(__x)))
+ {
+ __y = __x;
+ __x = _S_left(__x);
+ }
+ else
+ __x = _S_right(__x);
+ return const_iterator(__y);
}
template<typename _Kt,
pair<iterator, iterator>
_M_equal_range_tr(const _Kt& __k)
{
- auto __low = _M_lower_bound_tr(__k);
- auto __high = __low;
- auto& __cmp = _M_impl._M_key_compare;
- while (__high != end() && !__cmp(__k, _S_key(__high._M_node)))
- ++__high;
- return { __low, __high };
+ const _Rb_tree* __const_this = this;
+ auto __ret = __const_this->_M_equal_range_tr(__k);
+ return { __ret.first._M_const_cast(), __ret.second._M_const_cast() };
}
template<typename _Kt,
#endif
{
_Link_type __x = _M_begin();
- _Link_type __y = _M_end();
+ _Base_ptr __y = _M_end();
while (__x != 0)
{
__y = __x;
template<typename _NodeGen>
typename _Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::_Link_type
_Rb_tree<_Key, _Val, _KoV, _Compare, _Alloc>::
- _M_copy(_Const_Link_type __x, _Link_type __p, _NodeGen& __node_gen)
+ _M_copy(_Const_Link_type __x, _Base_ptr __p, _NodeGen& __node_gen)
{
// Structural copy. __x and __p must be non-null.
_Link_type __top = _M_clone_node(__x, __node_gen);
typename _Rb_tree<_Key, _Val, _KeyOfValue,
_Compare, _Alloc>::iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_lower_bound(_Link_type __x, _Link_type __y,
+ _M_lower_bound(_Link_type __x, _Base_ptr __y,
const _Key& __k)
{
while (__x != 0)
typename _Rb_tree<_Key, _Val, _KeyOfValue,
_Compare, _Alloc>::const_iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_lower_bound(_Const_Link_type __x, _Const_Link_type __y,
+ _M_lower_bound(_Const_Link_type __x, _Const_Base_ptr __y,
const _Key& __k) const
{
while (__x != 0)
typename _Rb_tree<_Key, _Val, _KeyOfValue,
_Compare, _Alloc>::iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_upper_bound(_Link_type __x, _Link_type __y,
+ _M_upper_bound(_Link_type __x, _Base_ptr __y,
const _Key& __k)
{
while (__x != 0)
typename _Rb_tree<_Key, _Val, _KeyOfValue,
_Compare, _Alloc>::const_iterator
_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::
- _M_upper_bound(_Const_Link_type __x, _Const_Link_type __y,
+ _M_upper_bound(_Const_Link_type __x, _Const_Base_ptr __y,
const _Key& __k) const
{
while (__x != 0)
equal_range(const _Key& __k)
{
_Link_type __x = _M_begin();
- _Link_type __y = _M_end();
+ _Base_ptr __y = _M_end();
while (__x != 0)
{
if (_M_impl._M_key_compare(_S_key(__x), __k))
__y = __x, __x = _S_left(__x);
else
{
- _Link_type __xu(__x), __yu(__y);
+ _Link_type __xu(__x);
+ _Base_ptr __yu(__y);
__y = __x, __x = _S_left(__x);
__xu = _S_right(__xu);
return pair<iterator,
equal_range(const _Key& __k) const
{
_Const_Link_type __x = _M_begin();
- _Const_Link_type __y = _M_end();
+ _Const_Base_ptr __y = _M_end();
while (__x != 0)
{
if (_M_impl._M_key_compare(_S_key(__x), __k))
__y = __x, __x = _S_left(__x);
else
{
- _Const_Link_type __xu(__x), __yu(__y);
+ _Const_Link_type __xu(__x);
+ _Const_Base_ptr __yu(__y);
__y = __x, __x = _S_left(__x);
__xu = _S_right(__xu);
return pair<const_iterator,
{
typedef pair<_Base_ptr, _Base_ptr> _Res;
_Link_type __x = _M_begin();
- _Link_type __y = _M_end();
+ _Base_ptr __y = _M_end();
bool __comp = true;
while (__x != 0)
{
{
typedef pair<_Base_ptr, _Base_ptr> _Res;
_Link_type __x = _M_begin();
- _Link_type __y = _M_end();
+ _Base_ptr __y = _M_end();
while (__x != 0)
{
__y = __x;
true);
}
- return _Res(iterator(static_cast<_Link_type>(__res.first)), false);
+ return _Res(iterator(__res.first), false);
}
template<typename _Key, typename _Val, typename _KeyOfValue,
return _M_insert_(__res.first, __res.second,
_GLIBCXX_FORWARD(_Arg, __v),
__node_gen);
- return iterator(static_cast<_Link_type>(__res.first));
+ return iterator(__res.first);
}
template<typename _Key, typename _Val, typename _KeyOfValue,
_M_insert_equal_lower_node(_Link_type __z)
{
_Link_type __x = _M_begin();
- _Link_type __y = _M_end();
+ _Base_ptr __y = _M_end();
while (__x != 0)
{
__y = __x;
return _Res(_M_insert_node(__res.first, __res.second, __z), true);
_M_drop_node(__z);
- return _Res(iterator(static_cast<_Link_type>(__res.first)), false);
+ return _Res(iterator(__res.first), false);
}
__catch(...)
{
return _M_insert_node(__res.first, __res.second, __z);
_M_drop_node(__z);
- return iterator(static_cast<_Link_type>(__res.first));
+ return iterator(__res.first);
}
__catch(...)
{