diff --git a/CHANGELOG.md b/CHANGELOG.md
index 33ccd970..54faa28f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,7 @@ Version 200
* Fix and refactor buffers_cat
* Refactor buffers_prefix
* Add const and mutable buffer sequence traits
+* Add buffers_iterator_type trait
API Changes:
diff --git a/doc/qbk/03_core/3_buffers.qbk b/doc/qbk/03_core/3_buffers.qbk
index 10237d59..a84a6944 100644
--- a/doc/qbk/03_core/3_buffers.qbk
+++ b/doc/qbk/03_core/3_buffers.qbk
@@ -165,6 +165,12 @@ metafunctions which operate on buffers:
[table Buffer Algorithms and Types
[[Name][Description]]
+[[
+ [link beast.ref.boost__beast__buffers_iterator_type `buffers_iterator_type`]
+][
+ This metafunction is used to determine the type of iterator
+ used by a particular buffer sequence.
+]]
[[
[link beast.ref.boost__beast__buffers_type `buffers_type`]
][
diff --git a/doc/qbk/quickref.xml b/doc/qbk/quickref.xml
index 297c7e40..fbbb3341 100644
--- a/doc/qbk/quickref.xml
+++ b/doc/qbk/quickref.xml
@@ -236,6 +236,7 @@
Type Traits
buffers_type
+ buffers_iterator_type
get_lowest_layer
has_get_executor
is_async_read_stream
diff --git a/include/boost/beast/core/buffer_traits.hpp b/include/boost/beast/core/buffer_traits.hpp
index 74ed663a..033ca778 100644
--- a/include/boost/beast/core/buffer_traits.hpp
+++ b/include/boost/beast/core/buffer_traits.hpp
@@ -12,6 +12,7 @@
#include
#include
+#include
#include
#include
@@ -103,6 +104,57 @@ using buffers_type = typename
net::const_buffer>::type;
#endif
+namespace detail {
+
+// VFALCO This is a workaround for MSVC.v140
+template
+struct buffers_iterator_type_helper
+{
+ using type = decltype(
+ net::buffer_sequence_begin(
+ std::declval()));
+};
+
+template<>
+struct buffers_iterator_type_helper<
+ net::const_buffer>
+{
+ using type = net::const_buffer const*;
+};
+
+template<>
+struct buffers_iterator_type_helper<
+ net::mutable_buffer>
+{
+ using type = net::mutable_buffer const*;
+};
+
+} // detail
+
+/** Type alias for the iterator type of a buffer sequence type.
+
+ This metafunction is used to determine the type of iterator
+ used by a particular buffer sequence.
+
+ @tparam T The buffer sequence type to use. The resulting
+ type alias will be equal to the iterator type used by
+ the buffer sequence.
+*/
+template
+#if BOOST_BEAST_DOXYGEN
+struct buffers_iterator_type : __see_below__ {};
+//using buffers_iterator_type = __see_below__;
+#else
+# if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
+using buffers_iterator_type = typename
+ detail::buffers_iterator_type_helper::type;
+# else
+using buffers_iterator_type =
+ decltype(net::buffer_sequence_begin(
+ std::declval()));
+# endif
+#endif
+
} // beast
} // boost
diff --git a/test/beast/core/buffer_traits.cpp b/test/beast/core/buffer_traits.cpp
index d27bff9f..5c4785d8 100644
--- a/test/beast/core/buffer_traits.cpp
+++ b/test/beast/core/buffer_traits.cpp
@@ -107,6 +107,18 @@ public:
std::array
>>::value);
+ // buffers_iterator_type
+
+ BOOST_STATIC_ASSERT(
+ std::is_same>::value);
+
+ BOOST_STATIC_ASSERT(
+ std::is_same>::value);
+
// javadoc: buffers_type
template
buffers_type