-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
#include <cstddef> // size_t | ||
#include <string> // string, to_string | ||
#include <iterator> // input_iterator_tag | ||
|
||
#include <nlohmann/detail/value_t.hpp> | ||
|
||
|
@@ -16,6 +17,13 @@ template<typename IteratorType> class iteration_proxy | |
/// helper class for iteration | ||
class iteration_proxy_internal | ||
{ | ||
public: | ||
using difference_type = std::ptrdiff_t; | ||
using value_type = iteration_proxy_internal; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
gregmarr
Contributor
|
||
using pointer = iteration_proxy_internal*; | ||
using reference = iteration_proxy_internal&; | ||
using iterator_category = std::input_iterator_tag; | ||
|
||
private: | ||
/// the iterator | ||
IteratorType anchor; | ||
|
@@ -25,6 +33,9 @@ template<typename IteratorType> class iteration_proxy | |
public: | ||
explicit iteration_proxy_internal(IteratorType it) noexcept : anchor(it) {} | ||
|
||
iteration_proxy_internal(const iteration_proxy_internal&) = default; | ||
iteration_proxy_internal& operator=(const iteration_proxy_internal&) = default; | ||
|
||
/// dereference operator (needed for range-based for) | ||
iteration_proxy_internal& operator*() | ||
{ | ||
|
@@ -40,6 +51,12 @@ template<typename IteratorType> class iteration_proxy | |
return *this; | ||
} | ||
|
||
/// equality operator (needed for InputIterator) | ||
bool operator==(const iteration_proxy_internal& o) const noexcept | ||
{ | ||
return anchor == o.anchor; | ||
} | ||
|
||
/// inequality operator (needed for range-based for) | ||
bool operator!=(const iteration_proxy_internal& o) const noexcept | ||
{ | ||
|
Shouldn't that be
typename IteratorType::value_type
? Or did I misunderstand the point of this class?