Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usages of the deprecated std::iterator #8088

Merged
merged 3 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/util/cmdline.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,15 @@ class cmdlinet
{
explicit option_namest(const cmdlinet &command_line);
struct option_names_iteratort
: public std::iterator<std::forward_iterator_tag, std::string>
{
// These types are defined such that the class is compatible with being
// treated as an STL iterator. For this to work, they must not be renamed.
using iterator_category = std::forward_iterator_tag;
using value_type = std::string;
using difference_type = std::ptrdiff_t;
using pointer = const std::string *;
using reference = const std::string &;

option_names_iteratort() = default;
explicit option_names_iteratort(
const cmdlinet *command_line,
Expand Down
16 changes: 10 additions & 6 deletions src/util/dense_integer_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,21 @@ class dense_integer_mapt
// operator++ that skips unset values.
template <class UnderlyingIterator, class UnderlyingValue>
class iterator_templatet
: public std::iterator<std::forward_iterator_tag, UnderlyingValue>
{
// Type of the std::iterator support class we inherit
typedef std::iterator<std::forward_iterator_tag, UnderlyingValue>
base_typet;
// Type of this template instantiation
typedef iterator_templatet<UnderlyingIterator, UnderlyingValue> self_typet;
// Type of our containing \ref dense_integer_mapt
typedef dense_integer_mapt<K, V, KeyToDenseInteger> map_typet;

public:
// These types are defined such that the class is compatible with being
// treated as an STL iterator. For this to work, they must not be renamed.
using iterator_category = std::forward_iterator_tag;
using value_type = UnderlyingValue;
using difference_type = std::ptrdiff_t;
using pointer = UnderlyingValue *;
using reference = UnderlyingValue &;

iterator_templatet(UnderlyingIterator it, const map_typet &underlying_map)
: underlying_iterator(it), underlying_map(underlying_map)
{
Expand All @@ -153,11 +157,11 @@ class dense_integer_mapt
underlying_iterator = advance(underlying_iterator);
return *this;
}
typename base_typet::reference operator*() const
reference operator*() const
{
return *underlying_iterator;
}
typename base_typet::pointer operator->() const
pointer operator->() const
{
return &*underlying_iterator;
}
Expand Down