mirror of
https://github.com/boostorg/unordered.git
synced 2025-11-12 21:49:51 +01:00
Implement proxy erase(iterator)
This commit is contained in:
@@ -348,17 +348,40 @@ public:
|
||||
>::type
|
||||
insert(element_type&& x){return emplace_impl(std::move(x));}
|
||||
|
||||
struct proxy_erase {
|
||||
const_iterator pos;
|
||||
operator iterator()const noexcept
|
||||
{
|
||||
auto it=pos;
|
||||
it.increment();
|
||||
return iterator(const_iterator_cast_tag{},it);
|
||||
}
|
||||
|
||||
template<
|
||||
bool dependent_value=false,
|
||||
typename std::enable_if<
|
||||
has_mutable_iterator||dependent_value>::type* =nullptr
|
||||
>
|
||||
operator const_iterator()const noexcept
|
||||
{
|
||||
auto it=pos;
|
||||
it.increment();
|
||||
return it;
|
||||
}
|
||||
};
|
||||
|
||||
template<
|
||||
bool dependent_value=false,
|
||||
typename std::enable_if<
|
||||
has_mutable_iterator||dependent_value>::type* =nullptr
|
||||
>
|
||||
void erase(iterator pos)noexcept{return erase(const_iterator(pos));}
|
||||
proxy_erase erase(iterator pos)noexcept{return erase(const_iterator(pos));}
|
||||
|
||||
BOOST_FORCEINLINE
|
||||
void erase(const_iterator pos)noexcept
|
||||
proxy_erase erase(const_iterator pos)noexcept
|
||||
{
|
||||
super::erase(pos.pc,pos.p);
|
||||
return proxy_erase{pos};
|
||||
}
|
||||
|
||||
template<typename Key>
|
||||
|
||||
@@ -381,11 +381,17 @@ namespace boost {
|
||||
.first;
|
||||
}
|
||||
|
||||
BOOST_FORCEINLINE void erase(iterator pos) { table_.erase(pos); }
|
||||
BOOST_FORCEINLINE void erase(const_iterator pos)
|
||||
BOOST_FORCEINLINE typename table_type::proxy_erase erase(iterator pos)
|
||||
{
|
||||
return table_.erase(pos);
|
||||
}
|
||||
|
||||
BOOST_FORCEINLINE typename table_type::proxy_erase erase(
|
||||
const_iterator pos)
|
||||
{
|
||||
return table_.erase(pos);
|
||||
}
|
||||
|
||||
iterator erase(const_iterator first, const_iterator last)
|
||||
{
|
||||
while (first != last) {
|
||||
|
||||
@@ -282,10 +282,12 @@ namespace boost {
|
||||
return table_.emplace(std::forward<Args>(args)...).first;
|
||||
}
|
||||
|
||||
BOOST_FORCEINLINE void erase(const_iterator pos)
|
||||
BOOST_FORCEINLINE typename table_type::proxy_erase erase(
|
||||
const_iterator pos)
|
||||
{
|
||||
return table_.erase(pos);
|
||||
}
|
||||
|
||||
iterator erase(const_iterator first, const_iterator last)
|
||||
{
|
||||
while (first != last) {
|
||||
|
||||
@@ -458,11 +458,17 @@ namespace boost {
|
||||
.first;
|
||||
}
|
||||
|
||||
BOOST_FORCEINLINE void erase(iterator pos) { table_.erase(pos); }
|
||||
BOOST_FORCEINLINE void erase(const_iterator pos)
|
||||
BOOST_FORCEINLINE typename table_type::proxy_erase erase(iterator pos)
|
||||
{
|
||||
return table_.erase(pos);
|
||||
}
|
||||
|
||||
BOOST_FORCEINLINE typename table_type::proxy_erase erase(
|
||||
const_iterator pos)
|
||||
{
|
||||
return table_.erase(pos);
|
||||
}
|
||||
|
||||
iterator erase(const_iterator first, const_iterator last)
|
||||
{
|
||||
while (first != last) {
|
||||
|
||||
@@ -352,10 +352,12 @@ namespace boost {
|
||||
return table_.emplace(std::forward<Args>(args)...).first;
|
||||
}
|
||||
|
||||
BOOST_FORCEINLINE void erase(const_iterator pos)
|
||||
BOOST_FORCEINLINE typename table_type::proxy_erase erase(
|
||||
const_iterator pos)
|
||||
{
|
||||
return table_.erase(pos);
|
||||
}
|
||||
|
||||
iterator erase(const_iterator first, const_iterator last)
|
||||
{
|
||||
while (first != last) {
|
||||
|
||||
Reference in New Issue
Block a user