mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-29 15:35:50 +00:00
Remove use of deprecated std::iterator
This commit is contained in:
committed by
Nik Bougalis
parent
47dec467ea
commit
f5af42a640
@@ -30,23 +30,21 @@ class aged_ordered_container;
|
||||
|
||||
namespace detail {
|
||||
|
||||
// Idea for Base template argument to prevent having to repeat
|
||||
// the base class declaration comes from newbiz on ##c++/Freenode
|
||||
//
|
||||
// If Iterator is SCARY then this iterator will be as well.
|
||||
template <
|
||||
bool is_const,
|
||||
class Iterator,
|
||||
class Base = std::iterator<
|
||||
typename std::iterator_traits<Iterator>::iterator_category,
|
||||
typename std::conditional<
|
||||
is_const,
|
||||
typename Iterator::value_type::stashed::value_type const,
|
||||
typename Iterator::value_type::stashed::value_type>::type,
|
||||
typename std::iterator_traits<Iterator>::difference_type>>
|
||||
class aged_container_iterator : public Base
|
||||
template <bool is_const, class Iterator>
|
||||
class aged_container_iterator
|
||||
{
|
||||
public:
|
||||
using iterator_category =
|
||||
typename std::iterator_traits<Iterator>::iterator_category;
|
||||
using value_type = typename std::conditional<
|
||||
is_const,
|
||||
typename Iterator::value_type::stashed::value_type const,
|
||||
typename Iterator::value_type::stashed::value_type>::type;
|
||||
using difference_type =
|
||||
typename std::iterator_traits<Iterator>::difference_type;
|
||||
using pointer = value_type*;
|
||||
using reference = value_type&;
|
||||
using time_point = typename Iterator::value_type::stashed::time_point;
|
||||
|
||||
aged_container_iterator() = default;
|
||||
@@ -56,13 +54,11 @@ public:
|
||||
template <
|
||||
bool other_is_const,
|
||||
class OtherIterator,
|
||||
class OtherBase,
|
||||
class = typename std::enable_if<
|
||||
(other_is_const == false || is_const == true) &&
|
||||
std::is_same<Iterator, OtherIterator>::value == false>::type>
|
||||
explicit aged_container_iterator(
|
||||
aged_container_iterator<other_is_const, OtherIterator, OtherBase> const&
|
||||
other)
|
||||
aged_container_iterator<other_is_const, OtherIterator> const& other)
|
||||
: m_iter(other.m_iter)
|
||||
{
|
||||
}
|
||||
@@ -70,22 +66,19 @@ public:
|
||||
// Disable constructing a const_iterator from a non-const_iterator.
|
||||
template <
|
||||
bool other_is_const,
|
||||
class OtherBase,
|
||||
class = typename std::enable_if<
|
||||
other_is_const == false || is_const == true>::type>
|
||||
aged_container_iterator(
|
||||
aged_container_iterator<other_is_const, Iterator, OtherBase> const&
|
||||
other)
|
||||
aged_container_iterator<other_is_const, Iterator> const& other)
|
||||
: m_iter(other.m_iter)
|
||||
{
|
||||
}
|
||||
|
||||
// Disable assigning a const_iterator to a non-const iterator
|
||||
template <bool other_is_const, class OtherIterator, class OtherBase>
|
||||
template <bool other_is_const, class OtherIterator>
|
||||
auto
|
||||
operator=(
|
||||
aged_container_iterator<other_is_const, OtherIterator, OtherBase> const&
|
||||
other) ->
|
||||
aged_container_iterator<other_is_const, OtherIterator> const& other) ->
|
||||
typename std::enable_if<
|
||||
other_is_const == false || is_const == true,
|
||||
aged_container_iterator&>::type
|
||||
@@ -94,20 +87,18 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <bool other_is_const, class OtherIterator, class OtherBase>
|
||||
template <bool other_is_const, class OtherIterator>
|
||||
bool
|
||||
operator==(
|
||||
aged_container_iterator<other_is_const, OtherIterator, OtherBase> const&
|
||||
other) const
|
||||
operator==(aged_container_iterator<other_is_const, OtherIterator> const&
|
||||
other) const
|
||||
{
|
||||
return m_iter == other.m_iter;
|
||||
}
|
||||
|
||||
template <bool other_is_const, class OtherIterator, class OtherBase>
|
||||
template <bool other_is_const, class OtherIterator>
|
||||
bool
|
||||
operator!=(
|
||||
aged_container_iterator<other_is_const, OtherIterator, OtherBase> const&
|
||||
other) const
|
||||
operator!=(aged_container_iterator<other_is_const, OtherIterator> const&
|
||||
other) const
|
||||
{
|
||||
return m_iter != other.m_iter;
|
||||
}
|
||||
@@ -142,13 +133,13 @@ public:
|
||||
return prev;
|
||||
}
|
||||
|
||||
typename Base::reference
|
||||
reference
|
||||
operator*() const
|
||||
{
|
||||
return m_iter->value;
|
||||
}
|
||||
|
||||
typename Base::pointer
|
||||
pointer
|
||||
operator->() const
|
||||
{
|
||||
return &m_iter->value;
|
||||
@@ -167,7 +158,7 @@ private:
|
||||
template <bool, bool, class, class, class, class, class, class>
|
||||
friend class aged_unordered_container;
|
||||
|
||||
template <bool, class, class>
|
||||
template <bool, class>
|
||||
friend class aged_container_iterator;
|
||||
|
||||
template <class OtherIterator>
|
||||
|
||||
@@ -989,22 +989,20 @@ public:
|
||||
template <
|
||||
bool is_const,
|
||||
class Iterator,
|
||||
class Base,
|
||||
class = std::enable_if_t<!is_boost_reverse_iterator<Iterator>::value>>
|
||||
beast::detail::aged_container_iterator<false, Iterator, Base>
|
||||
erase(beast::detail::aged_container_iterator<is_const, Iterator, Base> pos);
|
||||
beast::detail::aged_container_iterator<false, Iterator>
|
||||
erase(beast::detail::aged_container_iterator<is_const, Iterator> pos);
|
||||
|
||||
// enable_if prevents erase (reverse_iterator first, reverse_iterator last)
|
||||
// from compiling
|
||||
template <
|
||||
bool is_const,
|
||||
class Iterator,
|
||||
class Base,
|
||||
class = std::enable_if_t<!is_boost_reverse_iterator<Iterator>::value>>
|
||||
beast::detail::aged_container_iterator<false, Iterator, Base>
|
||||
beast::detail::aged_container_iterator<false, Iterator>
|
||||
erase(
|
||||
beast::detail::aged_container_iterator<is_const, Iterator, Base> first,
|
||||
beast::detail::aged_container_iterator<is_const, Iterator, Base> last);
|
||||
beast::detail::aged_container_iterator<is_const, Iterator> first,
|
||||
beast::detail::aged_container_iterator<is_const, Iterator> last);
|
||||
|
||||
template <class K>
|
||||
auto
|
||||
@@ -1019,10 +1017,9 @@ public:
|
||||
template <
|
||||
bool is_const,
|
||||
class Iterator,
|
||||
class Base,
|
||||
class = std::enable_if_t<!is_boost_reverse_iterator<Iterator>::value>>
|
||||
void
|
||||
touch(beast::detail::aged_container_iterator<is_const, Iterator, Base> pos)
|
||||
touch(beast::detail::aged_container_iterator<is_const, Iterator> pos)
|
||||
{
|
||||
touch(pos, clock().now());
|
||||
}
|
||||
@@ -1264,11 +1261,10 @@ private:
|
||||
template <
|
||||
bool is_const,
|
||||
class Iterator,
|
||||
class Base,
|
||||
class = std::enable_if_t<!is_boost_reverse_iterator<Iterator>::value>>
|
||||
void
|
||||
touch(
|
||||
beast::detail::aged_container_iterator<is_const, Iterator, Base> pos,
|
||||
beast::detail::aged_container_iterator<is_const, Iterator> pos,
|
||||
typename clock_type::time_point const& now);
|
||||
|
||||
template <
|
||||
@@ -2010,13 +2006,13 @@ template <
|
||||
class Clock,
|
||||
class Compare,
|
||||
class Allocator>
|
||||
template <bool is_const, class Iterator, class Base, class>
|
||||
beast::detail::aged_container_iterator<false, Iterator, Base>
|
||||
template <bool is_const, class Iterator, class>
|
||||
beast::detail::aged_container_iterator<false, Iterator>
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::
|
||||
erase(beast::detail::aged_container_iterator<is_const, Iterator, Base> pos)
|
||||
erase(beast::detail::aged_container_iterator<is_const, Iterator> pos)
|
||||
{
|
||||
unlink_and_delete_element(&*((pos++).iterator()));
|
||||
return beast::detail::aged_container_iterator<false, Iterator, Base>(
|
||||
return beast::detail::aged_container_iterator<false, Iterator>(
|
||||
pos.iterator());
|
||||
}
|
||||
|
||||
@@ -2028,17 +2024,17 @@ template <
|
||||
class Clock,
|
||||
class Compare,
|
||||
class Allocator>
|
||||
template <bool is_const, class Iterator, class Base, class>
|
||||
beast::detail::aged_container_iterator<false, Iterator, Base>
|
||||
template <bool is_const, class Iterator, class>
|
||||
beast::detail::aged_container_iterator<false, Iterator>
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::
|
||||
erase(
|
||||
beast::detail::aged_container_iterator<is_const, Iterator, Base> first,
|
||||
beast::detail::aged_container_iterator<is_const, Iterator, Base> last)
|
||||
beast::detail::aged_container_iterator<is_const, Iterator> first,
|
||||
beast::detail::aged_container_iterator<is_const, Iterator> last)
|
||||
{
|
||||
for (; first != last;)
|
||||
unlink_and_delete_element(&*((first++).iterator()));
|
||||
|
||||
return beast::detail::aged_container_iterator<false, Iterator, Base>(
|
||||
return beast::detail::aged_container_iterator<false, Iterator>(
|
||||
first.iterator());
|
||||
}
|
||||
|
||||
@@ -2173,11 +2169,11 @@ template <
|
||||
class Clock,
|
||||
class Compare,
|
||||
class Allocator>
|
||||
template <bool is_const, class Iterator, class Base, class>
|
||||
template <bool is_const, class Iterator, class>
|
||||
void
|
||||
aged_ordered_container<IsMulti, IsMap, Key, T, Clock, Compare, Allocator>::
|
||||
touch(
|
||||
beast::detail::aged_container_iterator<is_const, Iterator, Base> pos,
|
||||
beast::detail::aged_container_iterator<is_const, Iterator> pos,
|
||||
typename clock_type::time_point const& now)
|
||||
{
|
||||
auto& e(*pos.iterator());
|
||||
|
||||
@@ -1205,15 +1205,15 @@ public:
|
||||
return emplace<maybe_multi>(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
beast::detail::aged_container_iterator<false, Iterator, Base>
|
||||
erase(beast::detail::aged_container_iterator<is_const, Iterator, Base> pos);
|
||||
template <bool is_const, class Iterator>
|
||||
beast::detail::aged_container_iterator<false, Iterator>
|
||||
erase(beast::detail::aged_container_iterator<is_const, Iterator> pos);
|
||||
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
beast::detail::aged_container_iterator<false, Iterator, Base>
|
||||
template <bool is_const, class Iterator>
|
||||
beast::detail::aged_container_iterator<false, Iterator>
|
||||
erase(
|
||||
beast::detail::aged_container_iterator<is_const, Iterator, Base> first,
|
||||
beast::detail::aged_container_iterator<is_const, Iterator, Base> last);
|
||||
beast::detail::aged_container_iterator<is_const, Iterator> first,
|
||||
beast::detail::aged_container_iterator<is_const, Iterator> last);
|
||||
|
||||
template <class K>
|
||||
auto
|
||||
@@ -1222,9 +1222,9 @@ public:
|
||||
void
|
||||
swap(aged_unordered_container& other) noexcept;
|
||||
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
template <bool is_const, class Iterator>
|
||||
void
|
||||
touch(beast::detail::aged_container_iterator<is_const, Iterator, Base> pos)
|
||||
touch(beast::detail::aged_container_iterator<is_const, Iterator> pos)
|
||||
{
|
||||
touch(pos, clock().now());
|
||||
}
|
||||
@@ -1541,10 +1541,10 @@ private:
|
||||
insert_unchecked(first, last);
|
||||
}
|
||||
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
template <bool is_const, class Iterator>
|
||||
void
|
||||
touch(
|
||||
beast::detail::aged_container_iterator<is_const, Iterator, Base> pos,
|
||||
beast::detail::aged_container_iterator<is_const, Iterator> pos,
|
||||
typename clock_type::time_point const& now)
|
||||
{
|
||||
auto& e(*pos.iterator());
|
||||
@@ -3044,8 +3044,8 @@ template <
|
||||
class Hash,
|
||||
class KeyEqual,
|
||||
class Allocator>
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
beast::detail::aged_container_iterator<false, Iterator, Base>
|
||||
template <bool is_const, class Iterator>
|
||||
beast::detail::aged_container_iterator<false, Iterator>
|
||||
aged_unordered_container<
|
||||
IsMulti,
|
||||
IsMap,
|
||||
@@ -3054,11 +3054,11 @@ aged_unordered_container<
|
||||
Clock,
|
||||
Hash,
|
||||
KeyEqual,
|
||||
Allocator>::
|
||||
erase(beast::detail::aged_container_iterator<is_const, Iterator, Base> pos)
|
||||
Allocator>::erase(beast::detail::aged_container_iterator<is_const, Iterator>
|
||||
pos)
|
||||
{
|
||||
unlink_and_delete_element(&*((pos++).iterator()));
|
||||
return beast::detail::aged_container_iterator<false, Iterator, Base>(
|
||||
return beast::detail::aged_container_iterator<false, Iterator>(
|
||||
pos.iterator());
|
||||
}
|
||||
|
||||
@@ -3071,8 +3071,8 @@ template <
|
||||
class Hash,
|
||||
class KeyEqual,
|
||||
class Allocator>
|
||||
template <bool is_const, class Iterator, class Base>
|
||||
beast::detail::aged_container_iterator<false, Iterator, Base>
|
||||
template <bool is_const, class Iterator>
|
||||
beast::detail::aged_container_iterator<false, Iterator>
|
||||
aged_unordered_container<
|
||||
IsMulti,
|
||||
IsMap,
|
||||
@@ -3083,13 +3083,13 @@ aged_unordered_container<
|
||||
KeyEqual,
|
||||
Allocator>::
|
||||
erase(
|
||||
beast::detail::aged_container_iterator<is_const, Iterator, Base> first,
|
||||
beast::detail::aged_container_iterator<is_const, Iterator, Base> last)
|
||||
beast::detail::aged_container_iterator<is_const, Iterator> first,
|
||||
beast::detail::aged_container_iterator<is_const, Iterator> last)
|
||||
{
|
||||
for (; first != last;)
|
||||
unlink_and_delete_element(&*((first++).iterator()));
|
||||
|
||||
return beast::detail::aged_container_iterator<false, Iterator, Base>(
|
||||
return beast::detail::aged_container_iterator<false, Iterator>(
|
||||
first.iterator());
|
||||
}
|
||||
|
||||
|
||||
@@ -72,11 +72,12 @@ private:
|
||||
|
||||
template <typename N>
|
||||
class ListIterator
|
||||
: public std::iterator<std::bidirectional_iterator_tag, std::size_t>
|
||||
{
|
||||
public:
|
||||
using iterator_category = std::bidirectional_iterator_tag;
|
||||
using value_type =
|
||||
typename beast::detail::CopyConst<N, typename N::value_type>::type;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = value_type*;
|
||||
using reference = value_type&;
|
||||
using size_type = std::size_t;
|
||||
|
||||
@@ -29,18 +29,7 @@ namespace beast {
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template <class Container, bool IsConst>
|
||||
class LockFreeStackIterator : public std::iterator<
|
||||
std::forward_iterator_tag,
|
||||
typename Container::value_type,
|
||||
typename Container::difference_type,
|
||||
typename std::conditional<
|
||||
IsConst,
|
||||
typename Container::const_pointer,
|
||||
typename Container::pointer>::type,
|
||||
typename std::conditional<
|
||||
IsConst,
|
||||
typename Container::const_reference,
|
||||
typename Container::reference>::type>
|
||||
class LockFreeStackIterator
|
||||
{
|
||||
protected:
|
||||
using Node = typename Container::Node;
|
||||
@@ -48,7 +37,9 @@ protected:
|
||||
typename std::conditional<IsConst, Node const*, Node*>::type;
|
||||
|
||||
public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using value_type = typename Container::value_type;
|
||||
using difference_type = typename Container::difference_type;
|
||||
using pointer = typename std::conditional<
|
||||
IsConst,
|
||||
typename Container::const_pointer,
|
||||
|
||||
Reference in New Issue
Block a user