Ensure the iterator classes' value_type typedefs are non-const.
diff --git a/asio/include/asio/buffers_iterator.hpp b/asio/include/asio/buffers_iterator.hpp index dcca2d3..cec80aa 100644 --- a/asio/include/asio/buffers_iterator.hpp +++ b/asio/include/asio/buffers_iterator.hpp
@@ -17,9 +17,9 @@ #include "asio/detail/config.hpp" #include <cstddef> +#include <iterator> #include <boost/assert.hpp> #include <boost/detail/workaround.hpp> -#include <boost/iterator.hpp> #include <boost/type_traits/is_convertible.hpp> #include <boost/type_traits/add_const.hpp> #include "asio/buffer.hpp" @@ -72,18 +72,47 @@ /// A random access iterator over the bytes in a buffer sequence. template <typename BufferSequence, typename ByteType = char> class buffers_iterator - : public boost::iterator< - std::random_access_iterator_tag, - typename detail::buffers_iterator_types< - BufferSequence, ByteType>::byte_type> { private: typedef typename detail::buffers_iterator_types< BufferSequence, ByteType>::buffer_type buffer_type; - typedef typename detail::buffers_iterator_types< - BufferSequence, ByteType>::byte_type byte_type; public: + /// The type used for the distance between two iterators. + typedef std::ptrdiff_t difference_type; + + /// The type of the value pointed to by the iterator. + typedef ByteType value_type; + +#if defined(GENERATING_DOCUMENTATION) + /// The type of the result of applying operator->() to the iterator. + /** + * If the buffer sequence stores buffer objects that are convertible to + * mutable_buffer, this is a pointer to a non-const ByteType. Otherwise, a + * pointer to a const ByteType. + */ + typedef const_or_non_const_ByteType* pointer; +#else // defined(GENERATING_DOCUMENTATION) + typedef typename detail::buffers_iterator_types< + BufferSequence, ByteType>::byte_type* pointer; +#endif // defined(GENERATING_DOCUMENTATION) + +#if defined(GENERATING_DOCUMENTATION) + /// The type of the result of applying operator*() to the iterator. + /** + * If the buffer sequence stores buffer objects that are convertible to + * mutable_buffer, this is a reference to a non-const ByteType. Otherwise, a + * reference to a const ByteType. + */ + typedef const_or_non_const_ByteType& reference; +#else // defined(GENERATING_DOCUMENTATION) + typedef typename detail::buffers_iterator_types< + BufferSequence, ByteType>::byte_type& reference; +#endif // defined(GENERATING_DOCUMENTATION) + + /// The iterator category. + typedef std::random_access_iterator_tag iterator_category; + /// Default constructor. Creates an iterator in an undefined state. buffers_iterator() : current_buffer_(), @@ -135,19 +164,19 @@ } /// Dereference an iterator. - byte_type& operator*() const + reference operator*() const { return dereference(); } /// Dereference an iterator. - byte_type* operator->() const + pointer operator->() const { return &dereference(); } /// Access an individual element. - byte_type& operator[](std::ptrdiff_t difference) const + reference operator[](std::ptrdiff_t difference) const { buffers_iterator tmp(*this); tmp.advance(difference); @@ -270,9 +299,9 @@ private: // Dereference the iterator. - byte_type& dereference() const + reference dereference() const { - return buffer_cast<byte_type*>(current_buffer_)[current_buffer_position_]; + return buffer_cast<pointer>(current_buffer_)[current_buffer_position_]; } // Compare two iterators for equality.
diff --git a/asio/include/asio/ip/basic_resolver_iterator.hpp b/asio/include/asio/ip/basic_resolver_iterator.hpp index 033b7e0..981c842 100644 --- a/asio/include/asio/ip/basic_resolver_iterator.hpp +++ b/asio/include/asio/ip/basic_resolver_iterator.hpp
@@ -16,8 +16,9 @@ #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) #include "asio/detail/config.hpp" -#include <boost/iterator.hpp> +#include <cstddef> #include <cstring> +#include <iterator> #include <string> #include <vector> #include "asio/detail/shared_ptr.hpp" @@ -44,15 +45,23 @@ */ template <typename InternetProtocol> class basic_resolver_iterator -#if defined(GENERATING_DOCUMENTATION) - : public std::iterator< -#else // defined(GENERATING_DOCUMENTATION) - : public boost::iterator< -#endif // defined(GENERATING_DOCUMENTATION) - std::forward_iterator_tag, - const basic_resolver_entry<InternetProtocol> > { public: + /// The type used for the distance between two iterators. + typedef std::ptrdiff_t difference_type; + + /// The type of the value pointed to by the iterator. + typedef basic_resolver_entry<InternetProtocol> value_type; + + /// The type of the result of applying operator->() to the iterator. + typedef const basic_resolver_entry<InternetProtocol>* pointer; + + /// The type of the result of applying operator*() to the iterator. + typedef const basic_resolver_entry<InternetProtocol>& reference; + + /// The iterator category. + typedef std::forward_iterator_tag iterator_category; + /// Default constructor creates an end iterator. basic_resolver_iterator() : index_(0)