Browse Source

inherit from std::iterator<> to add some typedefs that make GNU G++ happy. Unfortunately, std::iterator<> is deprecated in C++17, for whatever reason. :-/

master
roker 4 years ago
parent
commit
2348e3a080
  1. 10
      src/wrapper.hh

10
src/wrapper.hh

@ -5,6 +5,7 @@
#define LIBPEPDATATYPES_WRAPPER_HH #define LIBPEPDATATYPES_WRAPPER_HH
#include <initializer_list> #include <initializer_list>
#include <iterator>
namespace pEp namespace pEp
{ {
@ -129,14 +130,15 @@ public:
static Element T::* const Value; // to access the current value static Element T::* const Value; // to access the current value
// does not own the *value // does not own the *value
class iterator class iterator : public std::iterator< std::forward_iterator_tag, Element, ptrdiff_t>
{ {
public: public:
iterator() = default; iterator() = default;
iterator operator++() { return (value ? value = value->next : value); } iterator operator++() { return (value ? value = value->next : value); }
Element operator*() { return value->*LW::Value; } Element operator*() { return value->*LW::Value; }
Element operator->() { return (value->*LW::Value); } Element operator->() { return value->*LW::Value; }
bool operator==(const iterator& other) const { return value == other.value; } bool operator==(const iterator& other) const { return value == other.value; }
bool operator!=(const iterator& other) const { return value != other.value; } bool operator!=(const iterator& other) const { return value != other.value; }

Loading…
Cancel
Save