Commit 64462816 authored by Philip's avatar Philip

Provide a specialisation of std::iterator_traits for IndexingIterator.

Only available when KJ_STD_COMPAT is defined.
parent 903d5bab
...@@ -27,7 +27,9 @@ ...@@ -27,7 +27,9 @@
#include "layout.h" #include "layout.h"
#include "orphan.h" #include "orphan.h"
#include <initializer_list> #include <initializer_list>
#ifdef KJ_STD_COMPAT
#include <iterator> #include <iterator>
#endif // KJ_STD_COMPAT
namespace capnp { namespace capnp {
namespace _ { // private namespace _ { // private
...@@ -49,7 +51,7 @@ private: ...@@ -49,7 +51,7 @@ private:
}; };
template <typename Container, typename Element> template <typename Container, typename Element>
class IndexingIterator : public std::iterator<std::random_access_iterator_tag, Element> { class IndexingIterator {
public: public:
IndexingIterator() = default; IndexingIterator() = default;
...@@ -507,4 +509,14 @@ private: ...@@ -507,4 +509,14 @@ private:
} // namespace capnp } // namespace capnp
#ifdef KJ_STD_COMPAT
namespace std {
template <typename Container, typename Element>
struct iterator_traits<capnp::_::IndexingIterator<Container, Element>>
: public std::iterator<std::random_access_iterator_tag, Element, int> {};
} // namespace std
#endif // KJ_STD_COMPAT
#endif // CAPNP_LIST_H_ #endif // CAPNP_LIST_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment