Skip to content

Commit

Permalink
Update the iterator implementation for C++17 (jbeder#575)
Browse files Browse the repository at this point in the history
Fix the compiler error which prevents deriving from std::iterator in C++17
  • Loading branch information
tankiJong authored and jbeder committed Apr 11, 2018
1 parent f996468 commit 124ae47
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions include/yaml-cpp/node/detail/iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@
#endif

#include "yaml-cpp/dll.h"
#include "yaml-cpp/node/detail/node_iterator.h"
#include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/detail/node_iterator.h"
#include <cstddef>
#include <iterator>


namespace YAML {
namespace detail {
struct iterator_value;

template <typename V>
class iterator_base : public std::iterator<std::forward_iterator_tag, V,
std::ptrdiff_t, V*, V> {
class iterator_base {

private:
template <typename>
Expand All @@ -37,7 +37,11 @@ class iterator_base : public std::iterator<std::forward_iterator_tag, V,
};

public:
typedef typename iterator_base::value_type value_type;
using iterator_category = std::forward_iterator_tag;
using value_type = V;
using difference_type = std::ptrdiff_t;
using pointer = V*;
using reference = V;

public:
iterator_base() : m_iterator(), m_pMemory() {}
Expand Down Expand Up @@ -86,7 +90,7 @@ class iterator_base : public std::iterator<std::forward_iterator_tag, V,
base_type m_iterator;
shared_memory_holder m_pMemory;
};
}
}
} // namespace detail
} // namespace YAML

#endif // VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66

0 comments on commit 124ae47

Please sign in to comment.