Update the iterator implementation for C++17 (#575)

Fix the compiler error which prevents deriving from std::iterator in C++17
This commit is contained in:
Tanki Zhang
2018-04-10 23:47:23 -05:00
committed by Jesse Beder
parent f996468a6a
commit 124ae47600

View File

@@ -8,19 +8,19 @@
#endif #endif
#include "yaml-cpp/dll.h" #include "yaml-cpp/dll.h"
#include "yaml-cpp/node/detail/node_iterator.h"
#include "yaml-cpp/node/node.h" #include "yaml-cpp/node/node.h"
#include "yaml-cpp/node/ptr.h" #include "yaml-cpp/node/ptr.h"
#include "yaml-cpp/node/detail/node_iterator.h"
#include <cstddef> #include <cstddef>
#include <iterator> #include <iterator>
namespace YAML { namespace YAML {
namespace detail { namespace detail {
struct iterator_value; struct iterator_value;
template <typename V> template <typename V>
class iterator_base : public std::iterator<std::forward_iterator_tag, V, class iterator_base {
std::ptrdiff_t, V*, V> {
private: private:
template <typename> template <typename>
@@ -37,7 +37,11 @@ class iterator_base : public std::iterator<std::forward_iterator_tag, V,
}; };
public: 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: public:
iterator_base() : m_iterator(), m_pMemory() {} iterator_base() : m_iterator(), m_pMemory() {}
@@ -86,7 +90,7 @@ class iterator_base : public std::iterator<std::forward_iterator_tag, V,
base_type m_iterator; base_type m_iterator;
shared_memory_holder m_pMemory; shared_memory_holder m_pMemory;
}; };
} } // namespace detail
} } // namespace YAML
#endif // VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 #endif // VALUE_DETAIL_ITERATOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66