mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 21:07:26 +02:00
Add buffers_iterator_type trait
This commit is contained in:
@ -8,6 +8,7 @@ Version 200
|
|||||||
* Fix and refactor buffers_cat
|
* Fix and refactor buffers_cat
|
||||||
* Refactor buffers_prefix
|
* Refactor buffers_prefix
|
||||||
* Add const and mutable buffer sequence traits
|
* Add const and mutable buffer sequence traits
|
||||||
|
* Add buffers_iterator_type trait
|
||||||
|
|
||||||
API Changes:
|
API Changes:
|
||||||
|
|
||||||
|
@ -165,6 +165,12 @@ metafunctions which operate on buffers:
|
|||||||
|
|
||||||
[table Buffer Algorithms and Types
|
[table Buffer Algorithms and Types
|
||||||
[[Name][Description]]
|
[[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`]
|
[link beast.ref.boost__beast__buffers_type `buffers_type`]
|
||||||
][
|
][
|
||||||
|
@ -236,6 +236,7 @@
|
|||||||
<bridgehead renderas="sect3">Type Traits</bridgehead>
|
<bridgehead renderas="sect3">Type Traits</bridgehead>
|
||||||
<simplelist type="vert" columns="1">
|
<simplelist type="vert" columns="1">
|
||||||
<member><link linkend="beast.ref.boost__beast__buffers_type">buffers_type</link></member>
|
<member><link linkend="beast.ref.boost__beast__buffers_type">buffers_type</link></member>
|
||||||
|
<member><link linkend="beast.ref.boost__beast__buffers_iterator_type">buffers_iterator_type</link></member>
|
||||||
<member><link linkend="beast.ref.boost__beast__get_lowest_layer">get_lowest_layer</link></member>
|
<member><link linkend="beast.ref.boost__beast__get_lowest_layer">get_lowest_layer</link></member>
|
||||||
<member><link linkend="beast.ref.boost__beast__has_get_executor">has_get_executor</link></member>
|
<member><link linkend="beast.ref.boost__beast__has_get_executor">has_get_executor</link></member>
|
||||||
<member><link linkend="beast.ref.boost__beast__is_async_read_stream">is_async_read_stream</link></member>
|
<member><link linkend="beast.ref.boost__beast__is_async_read_stream">is_async_read_stream</link></member>
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <boost/beast/core/detail/config.hpp>
|
#include <boost/beast/core/detail/config.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
#include <boost/mp11/function.hpp>
|
#include <boost/mp11/function.hpp>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
@ -103,6 +104,57 @@ using buffers_type = typename
|
|||||||
net::const_buffer>::type;
|
net::const_buffer>::type;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
// VFALCO This is a workaround for MSVC.v140
|
||||||
|
template<class T>
|
||||||
|
struct buffers_iterator_type_helper
|
||||||
|
{
|
||||||
|
using type = decltype(
|
||||||
|
net::buffer_sequence_begin(
|
||||||
|
std::declval<T const&>()));
|
||||||
|
};
|
||||||
|
|
||||||
|
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 <class T>
|
||||||
|
#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<T>::type;
|
||||||
|
# else
|
||||||
|
using buffers_iterator_type =
|
||||||
|
decltype(net::buffer_sequence_begin(
|
||||||
|
std::declval<T const&>()));
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
} // beast
|
} // beast
|
||||||
} // boost
|
} // boost
|
||||||
|
|
||||||
|
@ -107,6 +107,18 @@ public:
|
|||||||
std::array<int, 3>
|
std::array<int, 3>
|
||||||
>>::value);
|
>>::value);
|
||||||
|
|
||||||
|
// buffers_iterator_type
|
||||||
|
|
||||||
|
BOOST_STATIC_ASSERT(
|
||||||
|
std::is_same<net::const_buffer const*, buffers_iterator_type<
|
||||||
|
net::const_buffer
|
||||||
|
>>::value);
|
||||||
|
|
||||||
|
BOOST_STATIC_ASSERT(
|
||||||
|
std::is_same<net::mutable_buffer const*, buffers_iterator_type<
|
||||||
|
net::mutable_buffer
|
||||||
|
>>::value);
|
||||||
|
|
||||||
// javadoc: buffers_type
|
// javadoc: buffers_type
|
||||||
template <class BufferSequence>
|
template <class BufferSequence>
|
||||||
buffers_type <BufferSequence>
|
buffers_type <BufferSequence>
|
||||||
|
Reference in New Issue
Block a user