typedef typename _NodeTypes::__node_type __node;
typedef typename _NodeTypes::__node_pointer __node_pointer;
- typedef typename _NodeTypes::__node_pointer __node_const_pointer;
typedef typename _NodeTypes::__node_base_type __node_base;
typedef typename _NodeTypes::__node_base_pointer __node_base_pointer;
- typedef typename _NodeTypes::__node_base_pointer __node_base_const_pointer;
typedef typename _NodeTypes::__end_node_type __end_node_t;
typedef typename _NodeTypes::__end_node_pointer __end_node_ptr;
- typedef typename _NodeTypes::__end_node_pointer __end_node_const_ptr;
typedef typename __rebind_alloc_helper<__alloc_traits, __node>::type __node_allocator;
typedef allocator_traits<__node_allocator> __node_traits;
"Allocator does not rebind pointers in a sane manner.");
private:
- __node_pointer __begin_node_;
+ __node_pointer __begin_node_;
__compressed_pair<__end_node_t, __node_allocator> __pair1_;
__compressed_pair<size_type, value_compare> __pair3_;
_LIBCPP_INLINE_VISIBILITY
__node_pointer __end_node() _NOEXCEPT
{
- return static_cast<__node_pointer>
- (
- pointer_traits<__end_node_ptr>::pointer_to(__pair1_.first())
- );
+ return static_cast<__node_pointer>(
+ pointer_traits<__end_node_ptr>::pointer_to(__pair1_.first())
+ );
}
_LIBCPP_INLINE_VISIBILITY
- __node_const_pointer __end_node() const _NOEXCEPT
+ __node_pointer __end_node() const _NOEXCEPT
{
- return static_cast<__node_const_pointer>
- (
- pointer_traits<__end_node_const_ptr>::pointer_to(const_cast<__end_node_t&>(__pair1_.first()))
- );
+ return static_cast<__node_pointer>(
+ pointer_traits<__end_node_ptr>::pointer_to(
+ const_cast<__end_node_t&>(__pair1_.first())
+ )
+ );
}
_LIBCPP_INLINE_VISIBILITY
__node_allocator& __node_alloc() _NOEXCEPT {return __pair1_.second();}
const value_compare& value_comp() const _NOEXCEPT
{return __pair3_.second();}
public:
+
_LIBCPP_INLINE_VISIBILITY
- __node_pointer __root() _NOEXCEPT
- {return static_cast<__node_pointer> (__end_node()->__left_);}
- _LIBCPP_INLINE_VISIBILITY
- __node_const_pointer __root() const _NOEXCEPT
- {return static_cast<__node_const_pointer>(__end_node()->__left_);}
+ __node_pointer __root() const _NOEXCEPT
+ {return static_cast<__node_pointer>(__end_node()->__left_);}
typedef __tree_iterator<value_type, __node_pointer, difference_type> iterator;
typedef __tree_const_iterator<value_type, __node_pointer, difference_type> const_iterator;
{return __lower_bound(__v, __root(), __end_node());}
template <class _Key>
const_iterator __lower_bound(const _Key& __v,
- __node_const_pointer __root,
- __node_const_pointer __result) const;
+ __node_pointer __root,
+ __node_pointer __result) const;
template <class _Key>
_LIBCPP_INLINE_VISIBILITY
iterator upper_bound(const _Key& __v)
{return __upper_bound(__v, __root(), __end_node());}
template <class _Key>
const_iterator __upper_bound(const _Key& __v,
- __node_const_pointer __root,
- __node_const_pointer __result) const;
+ __node_pointer __root,
+ __node_pointer __result) const;
template <class _Key>
pair<iterator, iterator>
__equal_range_unique(const _Key& __k);
typename __tree<_Tp, _Compare, _Allocator>::size_type
__tree<_Tp, _Compare, _Allocator>::__count_unique(const _Key& __k) const
{
- __node_const_pointer __result = __end_node();
- __node_const_pointer __rt = __root();
+ __node_pointer __result = __end_node();
+ __node_pointer __rt = __root();
while (__rt != nullptr)
{
if (value_comp()(__k, __rt->__value_))
{
__result = __rt;
- __rt = static_cast<__node_const_pointer>(__rt->__left_);
+ __rt = static_cast<__node_pointer>(__rt->__left_);
}
else if (value_comp()(__rt->__value_, __k))
- __rt = static_cast<__node_const_pointer>(__rt->__right_);
+ __rt = static_cast<__node_pointer>(__rt->__right_);
else
return 1;
}
typename __tree<_Tp, _Compare, _Allocator>::size_type
__tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const
{
- __node_const_pointer __result = __end_node();
- __node_const_pointer __rt = __root();
+ __node_pointer __result = __end_node();
+ __node_pointer __rt = __root();
while (__rt != nullptr)
{
if (value_comp()(__k, __rt->__value_))
{
__result = __rt;
- __rt = static_cast<__node_const_pointer>(__rt->__left_);
+ __rt = static_cast<__node_pointer>(__rt->__left_);
}
else if (value_comp()(__rt->__value_, __k))
- __rt = static_cast<__node_const_pointer>(__rt->__right_);
+ __rt = static_cast<__node_pointer>(__rt->__right_);
else
return _VSTD::distance(
- __lower_bound(__k, static_cast<__node_const_pointer>(__rt->__left_), __rt),
- __upper_bound(__k, static_cast<__node_const_pointer>(__rt->__right_), __result)
+ __lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), __rt),
+ __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result)
);
}
return 0;
template <class _Key>
typename __tree<_Tp, _Compare, _Allocator>::const_iterator
__tree<_Tp, _Compare, _Allocator>::__lower_bound(const _Key& __v,
- __node_const_pointer __root,
- __node_const_pointer __result) const
+ __node_pointer __root,
+ __node_pointer __result) const
{
while (__root != nullptr)
{
if (!value_comp()(__root->__value_, __v))
{
__result = __root;
- __root = static_cast<__node_const_pointer>(__root->__left_);
+ __root = static_cast<__node_pointer>(__root->__left_);
}
else
- __root = static_cast<__node_const_pointer>(__root->__right_);
+ __root = static_cast<__node_pointer>(__root->__right_);
}
return const_iterator(__result);
}
template <class _Key>
typename __tree<_Tp, _Compare, _Allocator>::const_iterator
__tree<_Tp, _Compare, _Allocator>::__upper_bound(const _Key& __v,
- __node_const_pointer __root,
- __node_const_pointer __result) const
+ __node_pointer __root,
+ __node_pointer __result) const
{
while (__root != nullptr)
{
if (value_comp()(__v, __root->__value_))
{
__result = __root;
- __root = static_cast<__node_const_pointer>(__root->__left_);
+ __root = static_cast<__node_pointer>(__root->__left_);
}
else
- __root = static_cast<__node_const_pointer>(__root->__right_);
+ __root = static_cast<__node_pointer>(__root->__right_);
}
return const_iterator(__result);
}
__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const
{
typedef pair<const_iterator, const_iterator> _Pp;
- __node_const_pointer __result = __end_node();
- __node_const_pointer __rt = __root();
+ __node_pointer __result = __end_node();
+ __node_pointer __rt = __root();
while (__rt != nullptr)
{
if (value_comp()(__k, __rt->__value_))
{
__result = __rt;
- __rt = static_cast<__node_const_pointer>(__rt->__left_);
+ __rt = static_cast<__node_pointer>(__rt->__left_);
}
else if (value_comp()(__rt->__value_, __k))
- __rt = static_cast<__node_const_pointer>(__rt->__right_);
+ __rt = static_cast<__node_pointer>(__rt->__right_);
else
return _Pp(const_iterator(__rt),
const_iterator(
__rt->__right_ != nullptr ?
- static_cast<__node_const_pointer>(__tree_min(__rt->__right_))
+ static_cast<__node_pointer>(__tree_min(__rt->__right_))
: __result));
}
return _Pp(const_iterator(__result), const_iterator(__result));
__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const
{
typedef pair<const_iterator, const_iterator> _Pp;
- __node_const_pointer __result = __end_node();
- __node_const_pointer __rt = __root();
+ __node_pointer __result = __end_node();
+ __node_pointer __rt = __root();
while (__rt != nullptr)
{
if (value_comp()(__k, __rt->__value_))
{
__result = __rt;
- __rt = static_cast<__node_const_pointer>(__rt->__left_);
+ __rt = static_cast<__node_pointer>(__rt->__left_);
}
else if (value_comp()(__rt->__value_, __k))
- __rt = static_cast<__node_const_pointer>(__rt->__right_);
+ __rt = static_cast<__node_pointer>(__rt->__right_);
else
- return _Pp(__lower_bound(__k, static_cast<__node_const_pointer>(__rt->__left_), __rt),
- __upper_bound(__k, static_cast<__node_const_pointer>(__rt->__right_), __result));
+ return _Pp(__lower_bound(__k, static_cast<__node_pointer>(__rt->__left_), __rt),
+ __upper_bound(__k, static_cast<__node_pointer>(__rt->__right_), __result));
}
return _Pp(const_iterator(__result), const_iterator(__result));
}
typedef typename __base::__node __node;
typedef typename __base::__node_allocator __node_allocator;
typedef typename __base::__node_pointer __node_pointer;
- typedef typename __base::__node_const_pointer __node_const_pointer;
typedef typename __base::__node_base_pointer __node_base_pointer;
- typedef typename __base::__node_base_const_pointer __node_base_const_pointer;
+
typedef __map_node_destructor<__node_allocator> _Dp;
typedef unique_ptr<__node, _Dp> __node_holder;
#endif
__node_holder __construct_node_with_key(const key_type& __k);
+ __node_base_pointer const&
+ __find_equal_key(__node_base_pointer& __parent, const key_type& __k) const;
+
+ _LIBCPP_INLINE_VISIBILITY
__node_base_pointer&
- __find_equal_key(__node_base_pointer& __parent, const key_type& __k);
- __node_base_const_pointer
- __find_equal_key(__node_base_const_pointer& __parent, const key_type& __k) const;
+ __find_equal_key(__node_base_pointer& __parent, const key_type& __k) {
+ map const* __const_this = this;
+ return const_cast<__node_base_pointer&>(
+ __const_this->__find_equal_key(__parent, __k));
+ }
};
-// Find place to insert if __k doesn't exist
-// Set __parent to parent of null leaf
-// Return reference to null leaf
-// If __k exists, set parent to node of __k and return reference to node of __k
-template <class _Key, class _Tp, class _Compare, class _Allocator>
-typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_pointer&
-map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_pointer& __parent,
- const key_type& __k)
-{
- __node_pointer __nd = __tree_.__root();
- if (__nd != nullptr)
- {
- while (true)
- {
- if (__tree_.value_comp().key_comp()(__k, __nd->__value_.__cc.first))
- {
- if (__nd->__left_ != nullptr)
- __nd = static_cast<__node_pointer>(__nd->__left_);
- else
- {
- __parent = static_cast<__node_base_pointer>(__nd);
- return __parent->__left_;
- }
- }
- else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k))
- {
- if (__nd->__right_ != nullptr)
- __nd = static_cast<__node_pointer>(__nd->__right_);
- else
- {
- __parent = static_cast<__node_base_pointer>(__nd);
- return __parent->__right_;
- }
- }
- else
- {
- __parent = static_cast<__node_base_pointer>(__nd);
- return __parent;
- }
- }
- }
- __parent = static_cast<__node_base_pointer>(__tree_.__end_node());
- return __parent->__left_;
-}
// Find __k
// Set __parent to parent of null leaf and
// return reference to null leaf iv __k does not exist.
// If __k exists, set parent to node of __k and return reference to node of __k
template <class _Key, class _Tp, class _Compare, class _Allocator>
-typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_const_pointer
-map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_const_pointer& __parent,
+typename map<_Key, _Tp, _Compare, _Allocator>::__node_base_pointer const&
+map<_Key, _Tp, _Compare, _Allocator>::__find_equal_key(__node_base_pointer& __parent,
const key_type& __k) const
{
- __node_const_pointer __nd = __tree_.__root();
+ __node_pointer __nd = __tree_.__root();
if (__nd != nullptr)
{
while (true)
else
{
__parent = static_cast<__node_base_pointer>(__nd);
- return const_cast<const __node_base_const_pointer&>(__parent->__left_);
+ return __parent->__left_;
}
}
else if (__tree_.value_comp().key_comp()(__nd->__value_.__cc.first, __k))
else
{
__parent = static_cast<__node_base_pointer>(__nd);
- return const_cast<const __node_base_const_pointer&>(__parent->__right_);
+ return __parent->__right_;
}
}
else
}
}
__parent = static_cast<__node_base_pointer>(__tree_.__end_node());
- return const_cast<const __node_base_const_pointer&>(__parent->__left_);
+ return __parent->__left_;
}
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
const _Tp&
map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const
{
- __node_base_const_pointer __parent;
- __node_base_const_pointer __child = __find_equal_key(__parent, __k);
+ __node_base_pointer __parent;
+ __node_base_pointer __child = __find_equal_key(__parent, __k);
#ifndef _LIBCPP_NO_EXCEPTIONS
if (__child == nullptr)
throw out_of_range("map::at: key not found");
#endif // _LIBCPP_NO_EXCEPTIONS
- return static_cast<__node_const_pointer>(__child)->__value_.__cc.second;
+ return static_cast<__node_pointer>(__child)->__value_.__cc.second;
}
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
typedef typename __base::__node __node;
typedef typename __base::__node_allocator __node_allocator;
typedef typename __base::__node_pointer __node_pointer;
- typedef typename __base::__node_const_pointer __node_const_pointer;
+
typedef __map_node_destructor<__node_allocator> _Dp;
typedef unique_ptr<__node, _Dp> __node_holder;