summaryrefslogtreecommitdiff
path: root/boost/beast/core
diff options
context:
space:
mode:
Diffstat (limited to 'boost/beast/core')
-rw-r--r--boost/beast/core/basic_stream.hpp157
-rw-r--r--boost/beast/core/buffers_cat.hpp20
-rw-r--r--boost/beast/core/detail/base64.hpp21
-rw-r--r--boost/beast/core/detail/base64.ipp18
-rw-r--r--boost/beast/core/detail/buffers_range_adaptor.hpp17
-rw-r--r--boost/beast/core/detail/char_buffer.hpp78
-rw-r--r--boost/beast/core/detail/impl/read.hpp19
-rw-r--r--boost/beast/core/detail/impl/temporary_buffer.ipp69
-rw-r--r--boost/beast/core/detail/ostream.hpp1
-rw-r--r--boost/beast/core/detail/remap_post_to_defer.hpp1
-rw-r--r--boost/beast/core/detail/service_base.hpp9
-rw-r--r--boost/beast/core/detail/sha1.hpp3
-rw-r--r--boost/beast/core/detail/string.hpp44
-rw-r--r--boost/beast/core/detail/temporary_buffer.hpp83
-rw-r--r--boost/beast/core/detail/type_traits.hpp42
-rw-r--r--boost/beast/core/detail/variant.hpp20
-rw-r--r--boost/beast/core/detect_ssl.hpp3
-rw-r--r--boost/beast/core/impl/async_base.hpp24
-rw-r--r--boost/beast/core/impl/basic_stream.hpp116
-rw-r--r--boost/beast/core/impl/buffered_read_stream.hpp2
-rw-r--r--boost/beast/core/impl/buffers_adaptor.hpp1
-rw-r--r--boost/beast/core/impl/buffers_cat.hpp29
-rw-r--r--boost/beast/core/impl/flat_buffer.hpp2
-rw-r--r--boost/beast/core/impl/flat_stream.hpp2
-rw-r--r--boost/beast/core/impl/multi_buffer.hpp81
-rw-r--r--boost/beast/core/impl/read_size.hpp1
-rw-r--r--boost/beast/core/impl/static_buffer.hpp5
-rw-r--r--boost/beast/core/impl/static_buffer.ipp4
-rw-r--r--boost/beast/core/impl/static_string.hpp59
-rw-r--r--boost/beast/core/impl/string.ipp73
-rw-r--r--boost/beast/core/multi_buffer.hpp66
-rw-r--r--boost/beast/core/rate_policy.hpp2
-rw-r--r--boost/beast/core/span.hpp6
-rw-r--r--boost/beast/core/static_buffer.hpp8
-rw-r--r--boost/beast/core/static_string.hpp3
-rw-r--r--boost/beast/core/string.hpp98
-rw-r--r--boost/beast/core/string_param.hpp1
-rw-r--r--boost/beast/core/string_type.hpp45
38 files changed, 692 insertions, 541 deletions
diff --git a/boost/beast/core/basic_stream.hpp b/boost/beast/core/basic_stream.hpp
index 057ab07ffd..25076059e2 100644
--- a/boost/beast/core/basic_stream.hpp
+++ b/boost/beast/core/basic_stream.hpp
@@ -73,7 +73,7 @@ namespace beast {
be invoked by the executor associated with the stream upon construction.
The type of executor used with this stream must meet the following
requirements:
-
+
@li Function objects submitted to the executor shall never run
concurrently with each other.
@@ -284,6 +284,7 @@ private:
// but the implementation is still waiting on a timer.
boost::shared_ptr<impl_type> impl_;
+ template<class Executor2>
struct timeout_handler;
struct ops;
@@ -367,7 +368,7 @@ public:
/** Move constructor
- @param other The other object from which the move will occur.
+ @param other The other object from which the move will occur.
@note Following the move, the moved-from object is in the
same state as if newly constructed.
@@ -490,7 +491,7 @@ public:
//--------------------------------------------------------------------------
/** Get the executor associated with the object.
-
+
This function may be used to obtain the executor object that the
stream uses to dispatch completion handlers without an assocaited
executor.
@@ -498,7 +499,7 @@ public:
@return A copy of the executor that stream will use to dispatch handlers.
*/
executor_type
- get_executor() const noexcept
+ get_executor() noexcept
{
return impl_->ex();
}
@@ -525,7 +526,7 @@ public:
}
/** Connect the stream to the specified endpoint.
-
+
This function is used to connect the underlying socket to the
specified remote endpoint. The function call will block until
the connection is successfully made or an error occurs.
@@ -534,7 +535,7 @@ public:
closed state upon failure.
@param ep The remote endpoint to connect to.
-
+
@param ec Set to indicate what error occurred, if any.
@see connect
@@ -546,7 +547,7 @@ public:
}
/** Establishes a connection by trying each endpoint in a sequence.
-
+
This function attempts to connect the stream to one of a sequence of
endpoints by trying each endpoint until a connection is successfully
established.
@@ -556,11 +557,11 @@ public:
The algorithm, known as a <em>composed operation</em>, is implemented
in terms of calls to the underlying socket's `connect` function.
-
+
@param endpoints A sequence of endpoints.
-
+
@returns The successfully connected endpoint.
-
+
@throws system_error Thrown on failure. If the sequence is
empty, the associated error code is `net::error::not_found`.
Otherwise, contains the error from the last connection attempt.
@@ -579,7 +580,7 @@ public:
}
/** Establishes a connection by trying each endpoint in a sequence.
-
+
This function attempts to connect the stream to one of a sequence of
endpoints by trying each endpoint until a connection is successfully
established.
@@ -589,16 +590,16 @@ public:
The algorithm, known as a <em>composed operation</em>, is implemented
in terms of calls to the underlying socket's `connect` function.
-
+
@param endpoints A sequence of endpoints.
-
+
@param ec Set to indicate what error occurred, if any. If the sequence is
empty, set to `net::error::not_found`. Otherwise, contains the error
from the last connection attempt.
-
+
@returns On success, the successfully connected endpoint. Otherwise, a
default-constructed endpoint.
- */
+ */
template<class EndpointSequence
#if ! BOOST_BEAST_DOXYGEN
,class = typename std::enable_if<
@@ -616,27 +617,27 @@ public:
}
/** Establishes a connection by trying each endpoint in a sequence.
-
+
This function attempts to connect the stream to one of a sequence of
endpoints by trying each endpoint until a connection is successfully
established.
The underlying socket is automatically opened if needed.
An automatically opened socket is not returned to the
closed state upon failure.
-
+
The algorithm, known as a <em>composed operation</em>, is implemented
in terms of calls to the underlying socket's `connect` function.
-
+
@param begin An iterator pointing to the start of a sequence of endpoints.
-
+
@param end An iterator pointing to the end of a sequence of endpoints.
-
+
@returns An iterator denoting the successfully connected endpoint.
-
+
@throws system_error Thrown on failure. If the sequence is
empty, the associated error code is `net::error::not_found`.
Otherwise, contains the error from the last connection attempt.
- */
+ */
template<class Iterator>
Iterator
connect(
@@ -646,25 +647,25 @@ public:
}
/** Establishes a connection by trying each endpoint in a sequence.
-
+
This function attempts to connect the stream to one of a sequence of
endpoints by trying each endpoint until a connection is successfully
established.
The underlying socket is automatically opened if needed.
An automatically opened socket is not returned to the
closed state upon failure.
-
+
The algorithm, known as a <em>composed operation</em>, is implemented
in terms of calls to the underlying socket's `connect` function.
-
+
@param begin An iterator pointing to the start of a sequence of endpoints.
-
+
@param end An iterator pointing to the end of a sequence of endpoints.
-
+
@param ec Set to indicate what error occurred, if any. If the sequence is
empty, set to boost::asio::error::not_found. Otherwise, contains the error
from the last connection attempt.
-
+
@returns On success, an iterator denoting the successfully connected
endpoint. Otherwise, the end iterator.
*/
@@ -678,7 +679,7 @@ public:
}
/** Establishes a connection by trying each endpoint in a sequence.
-
+
This function attempts to connect the stream to one of a sequence of
endpoints by trying each endpoint until a connection is successfully
established.
@@ -688,9 +689,9 @@ public:
The algorithm, known as a <em>composed operation</em>, is implemented
in terms of calls to the underlying socket's `connect` function.
-
+
@param endpoints A sequence of endpoints.
-
+
@param connect_condition A function object that is called prior to each
connection attempt. The signature of the function object must be:
@code
@@ -703,9 +704,9 @@ public:
indicate success. The @c next parameter is the next endpoint to be tried.
The function object should return true if the next endpoint should be tried,
and false if it should be skipped.
-
+
@returns The successfully connected endpoint.
-
+
@throws boost::system::system_error Thrown on failure. If the sequence is
empty, the associated error code is `net::error::not_found`.
Otherwise, contains the error from the last connection attempt.
@@ -779,7 +780,7 @@ public:
}
/** Establishes a connection by trying each endpoint in a sequence.
-
+
This function attempts to connect the stream to one of a sequence of
endpoints by trying each endpoint until a connection is successfully
established.
@@ -789,11 +790,11 @@ public:
The algorithm, known as a <em>composed operation</em>, is implemented
in terms of calls to the underlying socket's `connect` function.
-
+
@param begin An iterator pointing to the start of a sequence of endpoints.
-
+
@param end An iterator pointing to the end of a sequence of endpoints.
-
+
@param connect_condition A function object that is called prior to each
connection attempt. The signature of the function object must be:
@code
@@ -806,13 +807,13 @@ public:
indicate success. The @c next parameter is the next endpoint to be tried.
The function object should return true if the next endpoint should be tried,
and false if it should be skipped.
-
+
@returns An iterator denoting the successfully connected endpoint.
-
+
@throws boost::system::system_error Thrown on failure. If the sequence is
empty, the associated @c error_code is `net::error::not_found`.
Otherwise, contains the error from the last connection attempt.
- */
+ */
template<
class Iterator, class ConnectCondition>
Iterator
@@ -824,7 +825,7 @@ public:
}
/** Establishes a connection by trying each endpoint in a sequence.
-
+
This function attempts to connect the stream to one of a sequence of
endpoints by trying each endpoint until a connection is successfully
established.
@@ -834,11 +835,11 @@ public:
The algorithm, known as a <em>composed operation</em>, is implemented
in terms of calls to the underlying socket's `connect` function.
-
+
@param begin An iterator pointing to the start of a sequence of endpoints.
-
+
@param end An iterator pointing to the end of a sequence of endpoints.
-
+
@param connect_condition A function object that is called prior to each
connection attempt. The signature of the function object must be:
@code
@@ -851,11 +852,11 @@ public:
indicate success. The @c next parameter is the next endpoint to be tried.
The function object should return true if the next endpoint should be tried,
and false if it should be skipped.
-
+
@param ec Set to indicate what error occurred, if any. If the sequence is
empty, set to `net::error::not_found`. Otherwise, contains the error
from the last connection attempt.
-
+
@returns On success, an iterator denoting the successfully connected
endpoint. Otherwise, the end iterator.
*/
@@ -885,7 +886,7 @@ public:
@param ep The remote endpoint to which the underlying socket will be
connected. Copies will be made of the endpoint object as required.
-
+
@param handler The completion handler to invoke when the operation
completes. The implementation takes ownership of the handler by
performing a decay-copy. The equivalent function signature of
@@ -909,7 +910,7 @@ public:
ConnectHandler&& handler);
/** Establishes a connection by trying each endpoint in a sequence asynchronously.
-
+
This function attempts to connect the stream to one of a sequence of
endpoints by trying each endpoint until a connection is successfully
established.
@@ -924,10 +925,10 @@ public:
If the timeout timer expires while the operation is outstanding,
the current connection attempt will be canceled and the completion
handler will be invoked with the error @ref error::timeout.
-
+
@param endpoints A sequence of endpoints. This this object must meet
the requirements of <em>EndpointSequence</em>.
-
+
@param handler The completion handler to invoke when the operation
completes. The implementation takes ownership of the handler by
performing a decay-copy. The equivalent function signature of
@@ -938,7 +939,7 @@ public:
// net::error::not_found. Otherwise, contains the
// error from the last connection attempt.
error_code const& error,
-
+
// On success, the successfully connected endpoint.
// Otherwise, a default-constructed endpoint.
typename Protocol::endpoint const& endpoint
@@ -964,7 +965,7 @@ public:
RangeConnectHandler&& handler);
/** Establishes a connection by trying each endpoint in a sequence asynchronously.
-
+
This function attempts to connect the stream to one of a sequence of
endpoints by trying each endpoint until a connection is successfully
established.
@@ -982,7 +983,7 @@ public:
@param endpoints A sequence of endpoints. This this object must meet
the requirements of <em>EndpointSequence</em>.
-
+
@param connect_condition A function object that is called prior to each
connection attempt. The signature of the function object must be:
@code
@@ -1006,7 +1007,7 @@ public:
// net::error::not_found. Otherwise, contains the
// error from the last connection attempt.
error_code const& error,
-
+
// On success, the successfully connected endpoint.
// Otherwise, a default-constructed endpoint.
typename Protocol::endpoint const& endpoint
@@ -1052,7 +1053,7 @@ public:
RangeConnectHandler&& handler);
/** Establishes a connection by trying each endpoint in a sequence asynchronously.
-
+
This function attempts to connect the stream to one of a sequence of
endpoints by trying each endpoint until a connection is successfully
established.
@@ -1067,9 +1068,9 @@ public:
If the timeout timer expires while the operation is outstanding,
the current connection attempt will be canceled and the completion
handler will be invoked with the error @ref error::timeout.
-
+
@param begin An iterator pointing to the start of a sequence of endpoints.
-
+
@param end An iterator pointing to the end of a sequence of endpoints.
@param handler The completion handler to invoke when the operation
@@ -1082,7 +1083,7 @@ public:
// net::error::not_found. Otherwise, contains the
// error from the last connection attempt.
error_code const& error,
-
+
// On success, an iterator denoting the successfully
// connected endpoint. Otherwise, the end iterator.
Iterator iterator
@@ -1102,7 +1103,7 @@ public:
IteratorConnectHandler&& handler);
/** Establishes a connection by trying each endpoint in a sequence asynchronously.
-
+
This function attempts to connect the stream to one of a sequence of
endpoints by trying each endpoint until a connection is successfully
established.
@@ -1113,11 +1114,11 @@ public:
If the timeout timer expires while the operation is outstanding,
the current connection attempt will be canceled and the completion
handler will be invoked with the error @ref error::timeout.
-
+
@param begin An iterator pointing to the start of a sequence of endpoints.
@param end An iterator pointing to the end of a sequence of endpoints.
-
+
@param connect_condition A function object that is called prior to each
connection attempt. The signature of the function object must be:
@code
@@ -1136,7 +1137,7 @@ public:
// net::error::not_found. Otherwise, contains the
// error from the last connection attempt.
error_code const& error,
-
+
// On success, an iterator denoting the successfully
// connected endpoint. Otherwise, the end iterator.
Iterator iterator
@@ -1162,7 +1163,7 @@ public:
/** Read some data.
This function is used to read some data from the stream.
-
+
The call blocks until one of the following is true:
@li One or more bytes are read from the stream.
@@ -1172,11 +1173,11 @@ public:
@param buffers The buffers into which the data will be read. If the
size of the buffers is zero bytes, the call always returns
immediately with no error.
-
+
@returns The number of bytes read.
-
+
@throws system_error Thrown on failure.
-
+
@note The `read_some` operation may not receive all of the requested
number of bytes. Consider using the function `net::read` if you need
to ensure that the requested amount of data is read before the
@@ -1202,11 +1203,11 @@ public:
@param buffers The buffers into which the data will be read. If the
size of the buffers is zero bytes, the call always returns
immediately with no error.
-
+
@param ec Set to indicate what error occurred, if any.
@returns The number of bytes read.
-
+
@note The `read_some` operation may not receive all of the requested
number of bytes. Consider using the function `net::read` if you need
to ensure that the requested amount of data is read before the
@@ -1224,7 +1225,7 @@ public:
/** Read some data asynchronously.
This function is used to asynchronously read data from the stream.
-
+
This call always returns immediately. The asynchronous operation
will continue until one of the following conditions is true:
@@ -1247,7 +1248,7 @@ public:
Although the buffers object may be copied as necessary, ownership of the
underlying memory blocks is retained by the caller, which must guarantee
that they remain valid until the handler is called.
-
+
@param handler The completion handler to invoke when the operation
completes. The implementation takes ownership of the handler by
performing a decay-copy. The equivalent function signature of
@@ -1277,7 +1278,7 @@ public:
/** Write some data.
This function is used to write some data to the stream.
-
+
The call blocks until one of the following is true:
@li One or more bytes are written to the stream.
@@ -1289,9 +1290,9 @@ public:
with no error.
@returns The number of bytes written.
-
+
@throws system_error Thrown on failure.
-
+
@note The `write_some` operation may not transmit all of the requested
number of bytes. Consider using the function `net::write` if you need
to ensure that the requested amount of data is written before the
@@ -1307,7 +1308,7 @@ public:
/** Write some data.
This function is used to write some data to the stream.
-
+
The call blocks until one of the following is true:
@li One or more bytes are written to the stream.
@@ -1321,9 +1322,9 @@ public:
@param ec Set to indicate what error occurred, if any.
@returns The number of bytes written.
-
+
@throws system_error Thrown on failure.
-
+
@note The `write_some` operation may not transmit all of the requested
number of bytes. Consider using the function `net::write` if you need
to ensure that the requested amount of data is written before the
@@ -1341,7 +1342,7 @@ public:
/** Write some data asynchronously.
This function is used to asynchronously write data to the underlying socket.
-
+
This call always returns immediately. The asynchronous operation
will continue until one of the following conditions is true:
@@ -1364,7 +1365,7 @@ public:
Although the buffers object may be copied as necessary, ownership of the
underlying memory blocks is retained by the caller, which must guarantee
that they remain valid until the handler is called.
-
+
@param handler The completion handler to invoke when the operation
completes. The implementation takes ownership of the handler by
performing a decay-copy. The equivalent function signature of
diff --git a/boost/beast/core/buffers_cat.hpp b/boost/beast/core/buffers_cat.hpp
index 532ea32eef..f13732916b 100644
--- a/boost/beast/core/buffers_cat.hpp
+++ b/boost/beast/core/buffers_cat.hpp
@@ -19,7 +19,6 @@ namespace boost {
namespace beast {
/** A buffer sequence representing a concatenation of buffer sequences.
-
@see buffers_cat
*/
template<class... Buffers>
@@ -29,7 +28,6 @@ class buffers_cat_view
public:
/** The type of buffer returned when dereferencing an iterator.
-
If every buffer sequence in the view is a <em>MutableBufferSequence</em>,
then `value_type` will be `net::mutable_buffer`.
Otherwise, `value_type` will be `net::const_buffer`.
@@ -50,7 +48,6 @@ public:
buffers_cat_view& operator=(buffers_cat_view const&) = default;
/** Constructor
-
@param buffers The list of buffer sequences to concatenate.
Copies of the arguments will be maintained for the lifetime
of the concatenated sequence; however, the ownership of the
@@ -63,12 +60,12 @@ public:
const_iterator
begin() const;
- /// Returns an iterator to one past the last buffer in the sequence
+ /// Returns an iterator to one past the last buffer in the sequence
const_iterator
end() const;
};
-/** Concatenate 2 or more buffer sequences.
+/** Concatenate 1 or more buffer sequences.
This function returns a constant or mutable buffer sequence which,
when iterated, efficiently concatenates the input buffer sequences.
@@ -76,15 +73,12 @@ public:
object does not take ownership of the underlying memory. The
application is still responsible for managing the lifetime of the
referenced memory.
-
@param buffers The list of buffer sequences to concatenate.
-
@return A new buffer sequence that represents the concatenation of
the input buffer sequences. This buffer sequence will be a
<em>MutableBufferSequence</em> if each of the passed buffer sequences is
also a <em>MutableBufferSequence</em>; otherwise the returned buffer
sequence will be a <em>ConstBufferSequence</em>.
-
@see buffers_cat_view
*/
#if BOOST_BEAST_DOXYGEN
@@ -92,15 +86,15 @@ template<class... BufferSequence>
buffers_cat_view<BufferSequence...>
buffers_cat(BufferSequence const&... buffers)
#else
-template<class B1, class B2, class... Bn>
-buffers_cat_view<B1, B2, Bn...>
-buffers_cat(B1 const& b1, B2 const& b2, Bn const&... bn)
+template<class B1, class... Bn>
+buffers_cat_view<B1, Bn...>
+buffers_cat(B1 const& b1, Bn const&... bn)
#endif
{
static_assert(
- is_const_buffer_sequence<B1, B2, Bn...>::value,
+ is_const_buffer_sequence<B1, Bn...>::value,
"BufferSequence type requirements not met");
- return buffers_cat_view<B1, B2, Bn...>{b1, b2, bn...};
+ return buffers_cat_view<B1, Bn...>{b1, bn...};
}
} // beast
diff --git a/boost/beast/core/detail/base64.hpp b/boost/beast/core/detail/base64.hpp
index 7f91c04777..477fecf2a6 100644
--- a/boost/beast/core/detail/base64.hpp
+++ b/boost/beast/core/detail/base64.hpp
@@ -12,7 +12,6 @@
#include <boost/beast/core/string.hpp>
#include <cctype>
-#include <string>
#include <utility>
namespace boost {
@@ -78,26 +77,6 @@ decode(void* dest, char const* src, std::size_t len);
} // base64
-BOOST_BEAST_DECL
-std::string
-base64_encode(std::uint8_t const* data, std::size_t len);
-
-BOOST_BEAST_DECL
-std::string
-base64_encode(string_view s);
-
-template<class = void>
-std::string
-base64_decode(string_view data)
-{
- std::string dest;
- dest.resize(base64::decoded_size(data.size()));
- auto const result = base64::decode(
- &dest[0], data.data(), data.size());
- dest.resize(result.first);
- return dest;
-}
-
} // detail
} // beast
} // boost
diff --git a/boost/beast/core/detail/base64.ipp b/boost/beast/core/detail/base64.ipp
index 7e11d188b6..4fc3c6771f 100644
--- a/boost/beast/core/detail/base64.ipp
+++ b/boost/beast/core/detail/base64.ipp
@@ -195,24 +195,6 @@ decode(void* dest, char const* src, std::size_t len)
} // base64
-std::string
-base64_encode(
- std::uint8_t const* data,
- std::size_t len)
-{
- std::string dest;
- dest.resize(base64::encoded_size(len));
- dest.resize(base64::encode(&dest[0], data, len));
- return dest;
-}
-
-std::string
-base64_encode(string_view s)
-{
- return base64_encode (reinterpret_cast <
- std::uint8_t const*> (s.data()), s.size());
-}
-
} // detail
} // beast
} // boost
diff --git a/boost/beast/core/detail/buffers_range_adaptor.hpp b/boost/beast/core/detail/buffers_range_adaptor.hpp
index 2e04d14f6d..e8e5147433 100644
--- a/boost/beast/core/detail/buffers_range_adaptor.hpp
+++ b/boost/beast/core/detail/buffers_range_adaptor.hpp
@@ -38,13 +38,9 @@ public:
buffers_iterator_type<BufferSequence>;
iter_type it_{};
- buffers_range_adaptor const* b_ = nullptr;
- const_iterator(
- buffers_range_adaptor const& b,
- iter_type const& it)
+ const_iterator(iter_type const& it)
: it_(it)
- , b_(&b)
{
}
@@ -62,7 +58,7 @@ public:
bool
operator==(const_iterator const& other) const
{
- return b_ == other.b_ && it_ == other.it_;
+ return it_ == other.it_;
}
bool
@@ -111,11 +107,6 @@ public:
}
};
- buffers_range_adaptor(
- buffers_range_adaptor const&) = default;
- buffers_range_adaptor& operator=(
- buffers_range_adaptor const&) = default;
-
explicit
buffers_range_adaptor(BufferSequence const& b)
: b_(b)
@@ -125,13 +116,13 @@ public:
const_iterator
begin() const noexcept
{
- return {*this, net::buffer_sequence_begin(b_)};
+ return {net::buffer_sequence_begin(b_)};
}
const_iterator
end() const noexcept
{
- return {*this, net::buffer_sequence_end(b_)};
+ return {net::buffer_sequence_end(b_)};
}
};
diff --git a/boost/beast/core/detail/char_buffer.hpp b/boost/beast/core/detail/char_buffer.hpp
new file mode 100644
index 0000000000..b1970ebc0a
--- /dev/null
+++ b/boost/beast/core/detail/char_buffer.hpp
@@ -0,0 +1,78 @@
+//
+// Copyright (c) 2019 Damian Jarek(damian.jarek93@gmail.com)
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// Official repository: https://github.com/boostorg/beast
+//
+
+#ifndef BOOST_BEAST_CORE_DETAIL_CHAR_BUFFER_HPP
+#define BOOST_BEAST_CORE_DETAIL_CHAR_BUFFER_HPP
+
+#include <boost/config.hpp>
+#include <cstddef>
+#include <cstring>
+#include <cstdint>
+
+namespace boost {
+namespace beast {
+namespace detail {
+
+template <std::size_t N>
+class char_buffer
+{
+public:
+ bool try_push_back(char c)
+ {
+ if (size_ == N)
+ return false;
+ buf_[size_++] = c;
+ return true;
+ }
+
+ bool try_append(char const* first, char const* last)
+ {
+ std::size_t const n = last - first;
+ if (n > N - size_)
+ return false;
+ std::memmove(&buf_[size_], first, n);
+ size_ += n;
+ return true;
+ }
+
+ void clear() noexcept
+ {
+ size_ = 0;
+ }
+
+ char* data() noexcept
+ {
+ return buf_;
+ }
+
+ char const* data() const noexcept
+ {
+ return buf_;
+ }
+
+ std::size_t size() const noexcept
+ {
+ return size_;
+ }
+
+ bool empty() const noexcept
+ {
+ return size_ == 0;
+ }
+
+private:
+ std::size_t size_= 0;
+ char buf_[N];
+};
+
+} // detail
+} // beast
+} // boost
+
+#endif
diff --git a/boost/beast/core/detail/impl/read.hpp b/boost/beast/core/detail/impl/read.hpp
index 137384aa40..3724979272 100644
--- a/boost/beast/core/detail/impl/read.hpp
+++ b/boost/beast/core/detail/impl/read.hpp
@@ -13,6 +13,7 @@
#include <boost/beast/core/bind_handler.hpp>
#include <boost/beast/core/async_base.hpp>
#include <boost/beast/core/flat_static_buffer.hpp>
+#include <boost/beast/core/read_size.hpp>
#include <boost/asio/basic_stream_socket.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/throw_exception.hpp>
@@ -37,7 +38,7 @@ template<
class Condition,
class Handler>
class read_op
- : public net::coroutine
+ : public asio::coroutine
, public async_base<
Handler, beast::executor_type<Stream>>
{
@@ -73,18 +74,12 @@ public:
std::size_t bytes_transferred,
bool cont = true)
{
- std::size_t max_size;
std::size_t max_prepare;
BOOST_ASIO_CORO_REENTER(*this)
{
for(;;)
{
- max_size = cond_(ec, total_, b_);
- max_prepare = std::min<std::size_t>(
- std::max<std::size_t>(
- 512, b_.capacity() - b_.size()),
- std::min<std::size_t>(
- max_size, b_.max_size() - b_.size()));
+ max_prepare = beast::read_size(b_, cond_(ec, total_, b_));
if(max_prepare == 0)
break;
BOOST_ASIO_CORO_YIELD
@@ -201,16 +196,10 @@ read(
"CompletionCondition type requirements not met");
ec = {};
std::size_t total = 0;
- std::size_t max_size;
std::size_t max_prepare;
for(;;)
{
- max_size = cond(ec, total, buffer);
- max_prepare = std::min<std::size_t>(
- std::max<std::size_t>(
- 512, buffer.capacity() - buffer.size()),
- std::min<std::size_t>(
- max_size, buffer.max_size() - buffer.size()));
+ max_prepare = beast::read_size(buffer, cond(ec, total, buffer));
if(max_prepare == 0)
break;
std::size_t const bytes_transferred =
diff --git a/boost/beast/core/detail/impl/temporary_buffer.ipp b/boost/beast/core/detail/impl/temporary_buffer.ipp
new file mode 100644
index 0000000000..932e847371
--- /dev/null
+++ b/boost/beast/core/detail/impl/temporary_buffer.ipp
@@ -0,0 +1,69 @@
+//
+// Copyright (c) 2019 Damian Jarek(damian.jarek93@gmail.com)
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// Official repository: https://github.com/boostorg/beast
+//
+
+#ifndef BOOST_BEAST_DETAIL_IMPL_TEMPORARY_BUFFER_IPP
+#define BOOST_BEAST_DETAIL_IMPL_TEMPORARY_BUFFER_IPP
+
+#include <boost/beast/core/detail/temporary_buffer.hpp>
+#include <boost/beast/core/detail/clamp.hpp>
+#include <boost/core/exchange.hpp>
+#include <boost/assert.hpp>
+#include <memory>
+#include <cstring>
+
+namespace boost {
+namespace beast {
+namespace detail {
+
+void
+temporary_buffer::
+append(string_view s)
+{
+ grow(s.size());
+ unchecked_append(s);
+}
+
+void
+temporary_buffer::
+append(string_view s1, string_view s2)
+{
+ grow(s1.size() + s2.size());
+ unchecked_append(s1);
+ unchecked_append(s2);
+}
+
+void
+temporary_buffer::
+unchecked_append(string_view s)
+{
+ auto n = s.size();
+ std::memcpy(&data_[size_], s.data(), n);
+ size_ += n;
+}
+
+void
+temporary_buffer::
+grow(std::size_t n)
+{
+ if (capacity_ - size_ >= n)
+ return;
+
+ auto const capacity = (n + size_) * 2u;
+ BOOST_ASSERT(! detail::sum_exceeds(
+ n, size_, capacity));
+ char* const p = new char[capacity];
+ std::memcpy(p, data_, size_);
+ deallocate(boost::exchange(data_, p));
+ capacity_ = capacity;
+}
+} // detail
+} // beast
+} // boost
+
+#endif
diff --git a/boost/beast/core/detail/ostream.hpp b/boost/beast/core/detail/ostream.hpp
index 65da560179..8785c2e6d8 100644
--- a/boost/beast/core/detail/ostream.hpp
+++ b/boost/beast/core/detail/ostream.hpp
@@ -12,7 +12,6 @@
#include <boost/beast/core/buffers_prefix.hpp>
#include <boost/beast/core/buffers_range.hpp>
-#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/throw_exception.hpp>
#include <boost/asio/buffer.hpp>
#include <memory>
diff --git a/boost/beast/core/detail/remap_post_to_defer.hpp b/boost/beast/core/detail/remap_post_to_defer.hpp
index 77f7d8ab20..850a833b52 100644
--- a/boost/beast/core/detail/remap_post_to_defer.hpp
+++ b/boost/beast/core/detail/remap_post_to_defer.hpp
@@ -10,7 +10,6 @@
#ifndef BOOST_BEAST_DETAIL_REMAP_POST_TO_DEFER_HPP
#define BOOST_BEAST_DETAIL_REMAP_POST_TO_DEFER_HPP
-#include <boost/asio/bind_executor.hpp>
#include <boost/asio/is_executor.hpp>
#include <boost/core/empty_value.hpp>
#include <type_traits>
diff --git a/boost/beast/core/detail/service_base.hpp b/boost/beast/core/detail/service_base.hpp
index adec09bbf1..1efe121516 100644
--- a/boost/beast/core/detail/service_base.hpp
+++ b/boost/beast/core/detail/service_base.hpp
@@ -17,14 +17,9 @@ namespace beast {
namespace detail {
template<class T>
-struct service_id : net::execution_context::id
-{
-};
-
-template<class T>
struct service_base : net::execution_context::service
{
- static service_id<T> id;
+ static net::execution_context::id const id;
explicit
service_base(net::execution_context& ctx)
@@ -34,7 +29,7 @@ struct service_base : net::execution_context::service
};
template<class T>
-service_id<T> service_base<T>::id;
+net::execution_context::id const service_base<T>::id;
} // detail
} // beast
diff --git a/boost/beast/core/detail/sha1.hpp b/boost/beast/core/detail/sha1.hpp
index abcc307407..c4c8d5e3fd 100644
--- a/boost/beast/core/detail/sha1.hpp
+++ b/boost/beast/core/detail/sha1.hpp
@@ -11,10 +11,7 @@
#define BOOST_BEAST_DETAIL_SHA1_HPP
#include <boost/beast/core/detail/config.hpp>
-
-#include <algorithm>
#include <cstdint>
-#include <cstring>
// Based on https://github.com/vog/sha1
/*
diff --git a/boost/beast/core/detail/string.hpp b/boost/beast/core/detail/string.hpp
new file mode 100644
index 0000000000..b553c60439
--- /dev/null
+++ b/boost/beast/core/detail/string.hpp
@@ -0,0 +1,44 @@
+//
+// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// Official repository: https://github.com/boostorg/beast
+//
+
+#ifndef BOOST_BEAST_DETAIL_STRING_HPP
+#define BOOST_BEAST_DETAIL_STRING_HPP
+
+#include <boost/beast/core/string_type.hpp>
+
+namespace boost {
+namespace beast {
+
+namespace detail {
+
+// Pulling in the UDL directly breaks in some places on MSVC,
+// so introduce a namespace for this purprose.
+namespace string_literals {
+
+inline
+string_view
+operator"" _sv(char const* p, std::size_t n)
+{
+ return string_view{p, n};
+}
+
+} // string_literals
+
+inline
+char
+ascii_tolower(char c)
+{
+ return ((static_cast<unsigned>(c) - 65U) < 26) ?
+ c + 'a' - 'A' : c;
+}
+} // detail
+} // beast
+} // boost
+
+#endif
diff --git a/boost/beast/core/detail/temporary_buffer.hpp b/boost/beast/core/detail/temporary_buffer.hpp
new file mode 100644
index 0000000000..8285b8f7eb
--- /dev/null
+++ b/boost/beast/core/detail/temporary_buffer.hpp
@@ -0,0 +1,83 @@
+//
+// Copyright (c) 2019 Damian Jarek(damian.jarek93@gmail.com)
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// Official repository: https://github.com/boostorg/beast
+//
+
+#ifndef BOOST_BEAST_DETAIL_TEMPORARY_BUFFER_HPP
+#define BOOST_BEAST_DETAIL_TEMPORARY_BUFFER_HPP
+
+#include <boost/beast/core/detail/config.hpp>
+#include <boost/beast/core/string.hpp>
+
+#include <memory>
+
+namespace boost {
+namespace beast {
+namespace detail {
+
+struct temporary_buffer
+{
+ temporary_buffer() = default;
+ temporary_buffer(temporary_buffer const&) = delete;
+ temporary_buffer& operator=(temporary_buffer const&) = delete;
+
+ ~temporary_buffer() noexcept
+ {
+ deallocate(data_);
+ }
+
+ BOOST_BEAST_DECL
+ void
+ append(string_view s);
+
+ BOOST_BEAST_DECL
+ void
+ append(string_view s1, string_view s2);
+
+ string_view
+ view() const noexcept
+ {
+ return {data_, size_};
+ }
+
+ bool
+ empty() const noexcept
+ {
+ return size_ == 0;
+ }
+
+private:
+ BOOST_BEAST_DECL
+ void
+ unchecked_append(string_view s);
+
+ BOOST_BEAST_DECL
+ void
+ grow(std::size_t n);
+
+ void
+ deallocate(char* data) noexcept
+ {
+ if (data != buffer_)
+ delete[] data;
+ }
+
+ char buffer_[4096];
+ char* data_ = buffer_;
+ std::size_t capacity_ = sizeof(buffer_);
+ std::size_t size_ = 0;
+};
+
+} // detail
+} // beast
+} // boost
+
+#ifdef BOOST_BEAST_HEADER_ONLY
+#include <boost/beast/core/detail/impl/temporary_buffer.ipp>
+#endif
+
+#endif
diff --git a/boost/beast/core/detail/type_traits.hpp b/boost/beast/core/detail/type_traits.hpp
index 3d895403b3..e94abbb179 100644
--- a/boost/beast/core/detail/type_traits.hpp
+++ b/boost/beast/core/detail/type_traits.hpp
@@ -10,36 +10,14 @@
#ifndef BOOST_BEAST_DETAIL_TYPE_TRAITS_HPP
#define BOOST_BEAST_DETAIL_TYPE_TRAITS_HPP
-#include <boost/beast/core/error.hpp>
-#include <boost/beast/core/detail/is_invocable.hpp>
-#include <boost/asio/buffer.hpp>
-#include <boost/mp11/function.hpp>
#include <boost/type_traits/make_void.hpp>
-#include <iterator>
-#include <tuple>
#include <type_traits>
-#include <string>
-#include <utility>
+#include <new>
namespace boost {
namespace beast {
namespace detail {
-// variadic min
-template<class T>
-T constexpr min(T t)
-{
- return t;
-}
-
-template<class T, class...Tn>
-T constexpr min(T t0, T t1, Tn... tn)
-{
- return (t0 < t1) ?
- (detail::min)(t0, tn...) :
- (detail::min)(t1, tn...);
-}
-
template<class U>
std::size_t constexpr
max_sizeof()
@@ -97,12 +75,6 @@ using aligned_union_t =
//------------------------------------------------------------------------------
-template<class T>
-void
-accept_rv(T){}
-
-//------------------------------------------------------------------------------
-
// for span
template<class T, class E, class = void>
struct is_contiguous_container: std::false_type {};
@@ -124,6 +96,18 @@ struct is_contiguous_container<T, E, void_t<
>::type>>: std::true_type
{};
+template <class T, class U>
+T launder_cast(U* u)
+{
+#if defined(__cpp_lib_launder) && __cpp_lib_launder >= 201606
+ return std::launder(reinterpret_cast<T>(u));
+#elif defined(BOOST_GCC) && BOOST_GCC_VERSION > 80000
+ return __builtin_launder(reinterpret_cast<T>(u));
+#else
+ return reinterpret_cast<T>(u);
+#endif
+}
+
} // detail
} // beast
} // boost
diff --git a/boost/beast/core/detail/variant.hpp b/boost/beast/core/detail/variant.hpp
index 94bd4c040c..f6f5b3c60b 100644
--- a/boost/beast/core/detail/variant.hpp
+++ b/boost/beast/core/detail/variant.hpp
@@ -45,7 +45,7 @@ class variant
{
using T =
mp11::mp_at_c<variant, I::value - 1>;
- reinterpret_cast<T&>(self.buf_).~T();
+ detail::launder_cast<T*>(&self.buf_)->~T();
}
};
@@ -64,7 +64,7 @@ class variant
using T =
mp11::mp_at_c<variant, I::value - 1>;
::new(&self.buf_) T(
- reinterpret_cast<T const&>(other.buf_));
+ *detail::launder_cast<T const*>(&other.buf_));
self.i_ = I::value;
}
};
@@ -83,9 +83,9 @@ class variant
{
using T =
mp11::mp_at_c<variant, I::value - 1>;
- ::new(&self.buf_) T(
- reinterpret_cast<T&&>(other.buf_));
- reinterpret_cast<T&>(other.buf_).~T();
+ ::new(&self.buf_) T(std::move(
+ *detail::launder_cast<T*>(&other.buf_)));
+ detail::launder_cast<T*>(&other.buf_)->~T();
self.i_ = I::value;
}
};
@@ -106,8 +106,8 @@ class variant
using T =
mp11::mp_at_c<variant, I::value - 1>;
return
- reinterpret_cast<T const&>(self.buf_) ==
- reinterpret_cast<T const&>(other.buf_);
+ *detail::launder_cast<T const*>(&self.buf_) ==
+ *detail::launder_cast<T const*>(&other.buf_);
}
};
@@ -181,7 +181,7 @@ public:
}
return *this;
}
-
+
variant& operator=(variant const& other)
{
if(this != &other)
@@ -208,7 +208,7 @@ public:
get()
{
BOOST_ASSERT(i_ == I);
- return *reinterpret_cast<
+ return *detail::launder_cast<
mp11::mp_at_c<variant, I - 1>*>(&buf_);
}
@@ -217,7 +217,7 @@ public:
get() const
{
BOOST_ASSERT(i_ == I);
- return *reinterpret_cast<
+ return *detail::launder_cast<
mp11::mp_at_c<variant, I - 1> const*>(&buf_);
}
diff --git a/boost/beast/core/detect_ssl.hpp b/boost/beast/core/detect_ssl.hpp
index b7b0550175..9281156819 100644
--- a/boost/beast/core/detect_ssl.hpp
+++ b/boost/beast/core/detect_ssl.hpp
@@ -430,7 +430,6 @@ async_detect_ssl(
// Non-const references need to be passed as pointers,
// since we don't want a decay-copy.
-
return net::async_initiate<
CompletionToken,
void(error_code, bool)>(
@@ -505,7 +504,7 @@ public:
AsyncReadStream& stream,
DynamicBuffer& buffer)
: beast::async_base<
- DetectHandler_,
+ DetectHandler,
beast::executor_type<AsyncReadStream>>(
std::forward<DetectHandler_>(handler),
stream.get_executor())
diff --git a/boost/beast/core/impl/async_base.hpp b/boost/beast/core/impl/async_base.hpp
index ec17b1cc1e..8dc8cb29a9 100644
--- a/boost/beast/core/impl/async_base.hpp
+++ b/boost/beast/core/impl/async_base.hpp
@@ -42,8 +42,9 @@ struct allocate_stable_state final
allocate_stable_state>;
A a(this->get());
- detail::allocator_traits<A>::destroy(a, this);
- detail::allocator_traits<A>::deallocate(a, this, 1);
+ auto* p = this;
+ p->~allocate_stable_state();
+ a.deallocate(p, 1);
}
};
@@ -118,33 +119,30 @@ allocate_stable(
{
using allocator_type = typename stable_async_base<
Handler, Executor1, Allocator>::allocator_type;
-
+ using state = detail::allocate_stable_state<
+ State, allocator_type>;
using A = typename detail::allocator_traits<
- allocator_type>::template rebind_alloc<
- detail::allocate_stable_state<
- State, allocator_type>>;
+ allocator_type>::template rebind_alloc<state>;
struct deleter
{
allocator_type alloc;
- detail::allocate_stable_state<
- State, allocator_type>* ptr;
+ state* ptr;
~deleter()
{
if(ptr)
{
A a(alloc);
- detail::allocator_traits<A>::deallocate(a, ptr, 1);
+ a.deallocate(ptr, 1);
}
}
};
A a(base.get_allocator());
- deleter d{base.get_allocator(), nullptr};
- d.ptr = detail::allocator_traits<A>::allocate(a, 1);
- detail::allocator_traits<A>::construct(a, d.ptr,
- d.alloc, std::forward<Args>(args)...);
+ deleter d{base.get_allocator(), a.allocate(1)};
+ ::new(static_cast<void*>(d.ptr))
+ state(d.alloc, std::forward<Args>(args)...);
d.ptr->next_ = base.list_;
base.list_ = d.ptr;
return boost::exchange(d.ptr, nullptr)->value;
diff --git a/boost/beast/core/impl/basic_stream.hpp b/boost/beast/core/impl/basic_stream.hpp
index c871944552..336c09f227 100644
--- a/boost/beast/core/impl/basic_stream.hpp
+++ b/boost/beast/core/impl/basic_stream.hpp
@@ -13,9 +13,7 @@
#include <boost/beast/core/async_base.hpp>
#include <boost/beast/core/buffer_traits.hpp>
#include <boost/beast/core/buffers_prefix.hpp>
-#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/beast/websocket/teardown.hpp>
-#include <boost/asio/bind_executor.hpp>
#include <boost/asio/coroutine.hpp>
#include <boost/assert.hpp>
#include <boost/make_shared.hpp>
@@ -161,12 +159,21 @@ close()
//------------------------------------------------------------------------------
template<class Protocol, class Executor, class RatePolicy>
+template<class Executor2>
struct basic_stream<Protocol, Executor, RatePolicy>::
timeout_handler
{
+ using executor_type = Executor2;
+
op_state& state;
boost::weak_ptr<impl_type> wp;
tick_type tick;
+ executor_type ex;
+
+ executor_type get_executor() const noexcept
+ {
+ return ex;
+ }
void
operator()(error_code ec)
@@ -212,62 +219,34 @@ class transfer_op
using is_read = std::integral_constant<bool, isRead>;
op_state&
- state(std::true_type)
- {
- return impl_->read;
- }
-
- op_state&
- state(std::false_type)
- {
- return impl_->write;
- }
-
- op_state&
state()
{
- return state(
- std::integral_constant<bool, isRead>{});
- }
-
- std::size_t
- available_bytes(std::true_type)
- {
- return rate_policy_access::
- available_read_bytes(impl_->policy());
- }
-
- std::size_t
- available_bytes(std::false_type)
- {
- return rate_policy_access::
- available_write_bytes(impl_->policy());
+ if (isRead)
+ return impl_->read;
+ else
+ return impl_->write;
}
std::size_t
available_bytes()
{
- return available_bytes(is_read{});
- }
-
- void
- transfer_bytes(std::size_t n, std::true_type)
- {
- rate_policy_access::
- transfer_read_bytes(impl_->policy(), n);
- }
-
- void
- transfer_bytes(std::size_t n, std::false_type)
- {
- rate_policy_access::
- transfer_write_bytes(impl_->policy(), n);
+ if (isRead)
+ return rate_policy_access::
+ available_read_bytes(impl_->policy());
+ else
+ return rate_policy_access::
+ available_write_bytes(impl_->policy());
}
void
transfer_bytes(std::size_t n)
{
- transfer_bytes(n, is_read{});
+ if (isRead)
+ rate_policy_access::
+ transfer_read_bytes(impl_->policy(), n);
+ else
+ rate_policy_access::
+ transfer_write_bytes(impl_->policy(), n);
}
void
@@ -329,13 +308,11 @@ public:
// if a timeout is active, wait on the timer
if(state().timer.expiry() != never())
state().timer.async_wait(
- net::bind_executor(
- this->get_executor(),
- timeout_handler{
- state(),
- impl_,
- state().tick
- }));
+ timeout_handler<decltype(this->get_executor())>{
+ state(),
+ impl_,
+ state().tick,
+ this->get_executor()});
// check rate limit, maybe wait
std::size_t amount;
@@ -430,12 +407,11 @@ public:
{
if(state().timer.expiry() != stream_base::never())
impl_->write.timer.async_wait(
- net::bind_executor(
- this->get_executor(),
- timeout_handler{
- state(),
- impl_,
- state().tick}));
+ timeout_handler<decltype(this->get_executor())>{
+ state(),
+ impl_,
+ state().tick,
+ this->get_executor()});
impl_->socket.async_connect(
ep, std::move(*this));
@@ -458,12 +434,11 @@ public:
{
if(state().timer.expiry() != stream_base::never())
impl_->write.timer.async_wait(
- net::bind_executor(
- this->get_executor(),
- timeout_handler{
- state(),
- impl_,
- state().tick}));
+ timeout_handler<decltype(this->get_executor())>{
+ state(),
+ impl_,
+ state().tick,
+ this->get_executor()});
net::async_connect(impl_->socket,
eps, cond, std::move(*this));
@@ -486,12 +461,11 @@ public:
{
if(state().timer.expiry() != stream_base::never())
impl_->write.timer.async_wait(
- net::bind_executor(
- this->get_executor(),
- timeout_handler{
- state(),
- impl_,
- state().tick}));
+ timeout_handler<decltype(this->get_executor())>{
+ state(),
+ impl_,
+ state().tick,
+ this->get_executor()});
net::async_connect(impl_->socket,
begin, end, cond, std::move(*this));
diff --git a/boost/beast/core/impl/buffered_read_stream.hpp b/boost/beast/core/impl/buffered_read_stream.hpp
index 184881164f..cea0dcb9fa 100644
--- a/boost/beast/core/impl/buffered_read_stream.hpp
+++ b/boost/beast/core/impl/buffered_read_stream.hpp
@@ -15,7 +15,7 @@
#include <boost/beast/core/error.hpp>
#include <boost/beast/core/read_size.hpp>
#include <boost/beast/core/stream_traits.hpp>
-#include <boost/beast/core/detail/type_traits.hpp>
+#include <boost/beast/core/detail/is_invocable.hpp>
#include <boost/asio/post.hpp>
#include <boost/throw_exception.hpp>
diff --git a/boost/beast/core/impl/buffers_adaptor.hpp b/boost/beast/core/impl/buffers_adaptor.hpp
index 91caad5463..3eac32f6e0 100644
--- a/boost/beast/core/impl/buffers_adaptor.hpp
+++ b/boost/beast/core/impl/buffers_adaptor.hpp
@@ -11,7 +11,6 @@
#define BOOST_BEAST_IMPL_BUFFERS_ADAPTOR_HPP
#include <boost/beast/core/buffer_traits.hpp>
-#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/config/workaround.hpp>
#include <boost/throw_exception.hpp>
diff --git a/boost/beast/core/impl/buffers_cat.hpp b/boost/beast/core/impl/buffers_cat.hpp
index 255153f2bd..a0506a0b35 100644
--- a/boost/beast/core/impl/buffers_cat.hpp
+++ b/boost/beast/core/impl/buffers_cat.hpp
@@ -11,7 +11,6 @@
#define BOOST_BEAST_IMPL_BUFFERS_CAT_HPP
#include <boost/beast/core/detail/tuple.hpp>
-#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/beast/core/detail/variant.hpp>
#include <boost/asio/buffer.hpp>
#include <cstdint>
@@ -23,6 +22,34 @@
namespace boost {
namespace beast {
+template<class Buffer>
+class buffers_cat_view<Buffer>
+{
+ Buffer buffer_;
+public:
+ using value_type = buffers_type<Buffer>;
+
+ using const_iterator = buffers_iterator_type<Buffer>;
+
+ explicit
+ buffers_cat_view(Buffer const& buffer)
+ : buffer_(buffer)
+ {
+ }
+
+ const_iterator
+ begin() const
+ {
+ return net::buffer_sequence_begin(buffer_);
+ }
+
+ const_iterator
+ end() const
+ {
+ return net::buffer_sequence_end(buffer_);
+ }
+};
+
#if defined(_MSC_VER) && ! defined(__clang__)
# define BOOST_BEAST_UNREACHABLE() __assume(false)
# define BOOST_BEAST_UNREACHABLE_RETURN(v) __assume(false)
diff --git a/boost/beast/core/impl/flat_buffer.hpp b/boost/beast/core/impl/flat_buffer.hpp
index f7fd51673d..83d3b4e74b 100644
--- a/boost/beast/core/impl/flat_buffer.hpp
+++ b/boost/beast/core/impl/flat_buffer.hpp
@@ -403,7 +403,7 @@ copy_from(
if(begin_)
{
BOOST_ASSERT(other.begin_);
- std::memcpy(begin_, other.begin_, n);
+ std::memcpy(begin_, other.in_, n);
}
}
diff --git a/boost/beast/core/impl/flat_stream.hpp b/boost/beast/core/impl/flat_stream.hpp
index 2972131198..f99ec02678 100644
--- a/boost/beast/core/impl/flat_stream.hpp
+++ b/boost/beast/core/impl/flat_stream.hpp
@@ -16,7 +16,6 @@
#include <boost/beast/core/stream_traits.hpp>
#include <boost/beast/websocket/teardown.hpp>
#include <boost/asio/buffer.hpp>
-#include <boost/asio/coroutine.hpp>
#include <memory>
namespace boost {
@@ -30,7 +29,6 @@ template<class Handler>
class write_op
: public async_base<Handler,
beast::executor_type<flat_stream>>
- , public net::coroutine
{
public:
template<
diff --git a/boost/beast/core/impl/multi_buffer.hpp b/boost/beast/core/impl/multi_buffer.hpp
index 643f60ce2b..29a10fa17b 100644
--- a/boost/beast/core/impl/multi_buffer.hpp
+++ b/boost/beast/core/impl/multi_buffer.hpp
@@ -11,7 +11,6 @@
#define BOOST_BEAST_IMPL_MULTI_BUFFER_HPP
#include <boost/beast/core/buffer_traits.hpp>
-#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/config/workaround.hpp>
#include <boost/core/exchange.hpp>
#include <boost/assert.hpp>
@@ -88,41 +87,6 @@ namespace beast {
in_pos_ out_pos_ == 0
out_end_ == 0
*/
-//------------------------------------------------------------------------------
-
-template<class Allocator>
-class basic_multi_buffer<Allocator>::element
- : public boost::intrusive::list_base_hook<
- boost::intrusive::link_mode<
- boost::intrusive::normal_link>>
-{
- using size_type = typename
- detail::allocator_traits<Allocator>::size_type;
-
- size_type const size_;
-
-public:
- element(element const&) = delete;
-
- explicit
- element(size_type n) noexcept
- : size_(n)
- {
- }
-
- size_type
- size() const noexcept
- {
- return size_;
- }
-
- char*
- data() const noexcept
- {
- return const_cast<char*>(
- reinterpret_cast<char const*>(this + 1));
- }
-};
//------------------------------------------------------------------------------
@@ -487,7 +451,7 @@ template<class Allocator>
basic_multi_buffer<Allocator>::
basic_multi_buffer(
Allocator const& alloc) noexcept
- : boost::empty_value<base_alloc_type>(
+ : boost::empty_value<Allocator>(
boost::empty_init_t(), alloc)
, max_(alloc_traits::max_size(this->get()))
, out_(list_.end())
@@ -499,8 +463,8 @@ basic_multi_buffer<Allocator>::
basic_multi_buffer(
std::size_t limit,
Allocator const& alloc) noexcept
- : boost::empty_value<
- base_alloc_type>(boost::empty_init_t(), alloc)
+ : boost::empty_value<Allocator>(
+ boost::empty_init_t(), alloc)
, max_(limit)
, out_(list_.end())
{
@@ -510,7 +474,7 @@ template<class Allocator>
basic_multi_buffer<Allocator>::
basic_multi_buffer(
basic_multi_buffer&& other) noexcept
- : boost::empty_value<base_alloc_type>(
+ : boost::empty_value<Allocator>(
boost::empty_init_t(), std::move(other.get()))
, max_(other.max_)
, in_size_(boost::exchange(other.in_size_, 0))
@@ -529,9 +493,9 @@ template<class Allocator>
basic_multi_buffer<Allocator>::
basic_multi_buffer(
basic_multi_buffer&& other,
- Allocator const& alloc)
- : boost::empty_value<
- base_alloc_type>(boost::empty_init_t(), alloc)
+ Allocator const& alloc)
+ : boost::empty_value<Allocator>(
+ boost::empty_init_t(), alloc)
, max_(other.max_)
{
if(this->get() != other.get())
@@ -562,7 +526,7 @@ template<class Allocator>
basic_multi_buffer<Allocator>::
basic_multi_buffer(
basic_multi_buffer const& other)
- : boost::empty_value<base_alloc_type>(
+ : boost::empty_value<Allocator>(
boost::empty_init_t(), alloc_traits::
select_on_container_copy_construction(
other.get()))
@@ -577,7 +541,7 @@ basic_multi_buffer<Allocator>::
basic_multi_buffer(
basic_multi_buffer const& other,
Allocator const& alloc)
- : boost::empty_value<base_alloc_type>(
+ : boost::empty_value<Allocator>(
boost::empty_init_t(), alloc)
, max_(other.max_)
, out_(list_.end())
@@ -601,8 +565,8 @@ basic_multi_buffer<Allocator>::
basic_multi_buffer(
basic_multi_buffer<OtherAlloc> const& other,
allocator_type const& alloc)
- : boost::empty_value<
- base_alloc_type>(boost::empty_init_t(), alloc)
+ : boost::empty_value<Allocator>(
+ boost::empty_init_t(), alloc)
, max_(other.max_)
, out_(list_.end())
{
@@ -1012,10 +976,7 @@ consume(size_type n) noexcept
in_pos_ = 0;
auto& e = list_.front();
list_.erase(list_.iterator_to(e));
- auto const len = sizeof(e) + e.size();
- e.~element();
- alloc_traits::deallocate(this->get(),
- reinterpret_cast<char*>(&e), len);
+ destroy(e);
#if BOOST_BEAST_MULTI_BUFFER_DEBUG_CHECK
debug_check();
#endif
@@ -1216,10 +1177,14 @@ void
basic_multi_buffer<Allocator>::
destroy(element& e)
{
- auto const len = sizeof(e) + e.size();
+ auto a = rebind_type{this->get()};
+ auto const n =
+ (sizeof(element) + e.size() +
+ sizeof(align_type) - 1) /
+ sizeof(align_type);
e.~element();
- alloc_traits::deallocate(this->get(),
- reinterpret_cast<char*>(&e), len);
+ alloc_traits::deallocate(a,
+ reinterpret_cast<align_type*>(&e), n);
}
template<class Allocator>
@@ -1231,9 +1196,11 @@ alloc(std::size_t size) ->
if(size > alloc_traits::max_size(this->get()))
BOOST_THROW_EXCEPTION(std::length_error(
"A basic_multi_buffer exceeded the allocator's maximum size"));
- return *::new(alloc_traits::allocate(
- this->get(),
- sizeof(element) + size)) element(size);
+ auto a = rebind_type{this->get()};
+ auto const p = alloc_traits::allocate(a,
+ (sizeof(element) + size + sizeof(align_type) - 1) /
+ sizeof(align_type));
+ return *(::new(p) element(size));
}
template<class Allocator>
diff --git a/boost/beast/core/impl/read_size.hpp b/boost/beast/core/impl/read_size.hpp
index 1896c014b8..babbcaac11 100644
--- a/boost/beast/core/impl/read_size.hpp
+++ b/boost/beast/core/impl/read_size.hpp
@@ -46,7 +46,6 @@ read_size(DynamicBuffer& buffer,
static_assert(
net::is_dynamic_buffer<DynamicBuffer>::value,
"DynamicBuffer type requirements not met");
- BOOST_ASSERT(max_size >= 1);
auto const size = buffer.size();
auto const limit = buffer.max_size() - size;
BOOST_ASSERT(size <= buffer.max_size());
diff --git a/boost/beast/core/impl/static_buffer.hpp b/boost/beast/core/impl/static_buffer.hpp
index dee13bfbe5..ae4f53c1b5 100644
--- a/boost/beast/core/impl/static_buffer.hpp
+++ b/boost/beast/core/impl/static_buffer.hpp
@@ -10,12 +10,7 @@
#ifndef BOOST_BEAST_IMPL_STATIC_BUFFER_HPP
#define BOOST_BEAST_IMPL_STATIC_BUFFER_HPP
-#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/asio/buffer.hpp>
-#include <boost/throw_exception.hpp>
-#include <algorithm>
-#include <cstring>
-#include <iterator>
#include <stdexcept>
namespace boost {
diff --git a/boost/beast/core/impl/static_buffer.ipp b/boost/beast/core/impl/static_buffer.ipp
index c26ff429b8..b87d704b65 100644
--- a/boost/beast/core/impl/static_buffer.ipp
+++ b/boost/beast/core/impl/static_buffer.ipp
@@ -11,12 +11,8 @@
#define BOOST_BEAST_IMPL_STATIC_BUFFER_IPP
#include <boost/beast/core/static_buffer.hpp>
-#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/asio/buffer.hpp>
#include <boost/throw_exception.hpp>
-#include <algorithm>
-#include <cstring>
-#include <iterator>
#include <stdexcept>
namespace boost {
diff --git a/boost/beast/core/impl/static_string.hpp b/boost/beast/core/impl/static_string.hpp
index c668b837fa..2e3e5617ab 100644
--- a/boost/beast/core/impl/static_string.hpp
+++ b/boost/beast/core/impl/static_string.hpp
@@ -11,7 +11,6 @@
#define BOOST_BEAST_IMPL_STATIC_STRING_HPP
#include <boost/beast/core/detail/static_string.hpp>
-#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/throw_exception.hpp>
namespace boost {
@@ -559,64 +558,6 @@ assign_char(CharT, std::false_type) ->
"max_size() == 0"});
}
-namespace detail {
-
-template<class Integer>
-static_string<max_digits(sizeof(Integer))>
-to_static_string(Integer x, std::true_type)
-{
- if(x == 0)
- return {'0'};
- static_string<detail::max_digits(
- sizeof(Integer))> s;
- if(x < 0)
- {
- x = -x;
- char buf[max_digits(sizeof(x))];
- char* p = buf;
- for(;x > 0; x /= 10)
- *p++ = "0123456789"[x % 10];
- s.resize(1 + p - buf);
- s[0] = '-';
- auto d = &s[1];
- while(p > buf)
- *d++ = *--p;
- }
- else
- {
- char buf[max_digits(sizeof(x))];
- char* p = buf;
- for(;x > 0; x /= 10)
- *p++ = "0123456789"[x % 10];
- s.resize(p - buf);
- auto d = &s[0];
- while(p > buf)
- *d++ = *--p;
- }
- return s;
-}
-
-template<class Integer>
-static_string<max_digits(sizeof(Integer))>
-to_static_string(Integer x, std::false_type)
-{
- if(x == 0)
- return {'0'};
- char buf[max_digits(sizeof(x))];
- char* p = buf;
- for(;x > 0; x /= 10)
- *p++ = "0123456789"[x % 10];
- static_string<detail::max_digits(
- sizeof(Integer))> s;
- s.resize(p - buf);
- auto d = &s[0];
- while(p > buf)
- *d++ = *--p;
- return s;
-}
-
-} // detail
-
template<class Integer, class>
static_string<detail::max_digits(sizeof(Integer))>
to_static_string(Integer x)
diff --git a/boost/beast/core/impl/string.ipp b/boost/beast/core/impl/string.ipp
new file mode 100644
index 0000000000..b64ce3f6aa
--- /dev/null
+++ b/boost/beast/core/impl/string.ipp
@@ -0,0 +1,73 @@
+//
+// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// Official repository: https://github.com/boostorg/beast
+//
+
+#ifndef BOOST_BEAST_IMPL_STRING_IPP
+#define BOOST_BEAST_IMPL_STRING_IPP
+
+#include <boost/beast/core/string.hpp>
+#include <boost/beast/core/detail/string.hpp>
+
+#include <algorithm>
+
+namespace boost {
+namespace beast {
+
+bool
+iequals(
+ beast::string_view lhs,
+ beast::string_view rhs)
+{
+ auto n = lhs.size();
+ if(rhs.size() != n)
+ return false;
+ auto p1 = lhs.data();
+ auto p2 = rhs.data();
+ char a, b;
+ // fast loop
+ while(n--)
+ {
+ a = *p1++;
+ b = *p2++;
+ if(a != b)
+ goto slow;
+ }
+ return true;
+slow:
+ do
+ {
+ if( detail::ascii_tolower(a) !=
+ detail::ascii_tolower(b))
+ return false;
+ a = *p1++;
+ b = *p2++;
+ }
+ while(n--);
+ return true;
+}
+
+bool
+iless::operator()(
+ string_view lhs,
+ string_view rhs) const
+{
+ using std::begin;
+ using std::end;
+ return std::lexicographical_compare(
+ begin(lhs), end(lhs), begin(rhs), end(rhs),
+ [](char c1, char c2)
+ {
+ return detail::ascii_tolower(c1) < detail::ascii_tolower(c2);
+ }
+ );
+}
+
+} // beast
+} // boost
+
+#endif
diff --git a/boost/beast/core/multi_buffer.hpp b/boost/beast/core/multi_buffer.hpp
index 2cf477a83b..837310c004 100644
--- a/boost/beast/core/multi_buffer.hpp
+++ b/boost/beast/core/multi_buffer.hpp
@@ -15,6 +15,7 @@
#include <boost/asio/buffer.hpp>
#include <boost/core/empty_value.hpp>
#include <boost/intrusive/list.hpp>
+#include <boost/type_traits/type_with_alignment.hpp>
#include <iterator>
#include <limits>
#include <memory>
@@ -62,14 +63,13 @@ namespace beast {
template<class Allocator>
class basic_multi_buffer
#if ! BOOST_BEAST_DOXYGEN
- : private boost::empty_value<
- typename detail::allocator_traits<Allocator>::
- template rebind_alloc<char>>
+ : private boost::empty_value<Allocator>
#endif
{
- using base_alloc_type = typename
- detail::allocator_traits<Allocator>::
- template rebind_alloc<char>;
+ // Fancy pointers are not supported
+ static_assert(std::is_pointer<typename
+ std::allocator_traits<Allocator>::pointer>::value,
+ "Allocator must use regular pointers");
static bool constexpr default_nothrow =
std::is_nothrow_default_constructible<Allocator>::value;
@@ -77,19 +77,61 @@ class basic_multi_buffer
// Storage for the list of buffers representing the input
// and output sequences. The allocation for each element
// contains `element` followed by raw storage bytes.
- class element;
+ class element
+ : public boost::intrusive::list_base_hook<
+ boost::intrusive::link_mode<
+ boost::intrusive::normal_link>>
+ {
+ using size_type = typename
+ detail::allocator_traits<Allocator>::size_type;
+
+ size_type const size_;
+
+ public:
+ element(element const&) = delete;
+
+ explicit
+ element(size_type n) noexcept
+ : size_(n)
+ {
+ }
+
+ size_type
+ size() const noexcept
+ {
+ return size_;
+ }
+
+ char*
+ data() const noexcept
+ {
+ return const_cast<char*>(
+ reinterpret_cast<char const*>(this + 1));
+ }
+ };
template<bool>
class readable_bytes;
+ using size_type = typename
+ detail::allocator_traits<Allocator>::size_type;
+
+ using align_type = typename
+ boost::type_with_alignment<alignof(element)>::type;
+
+ using rebind_type = typename
+ beast::detail::allocator_traits<Allocator>::
+ template rebind_alloc<align_type>;
+
using alloc_traits =
- beast::detail::allocator_traits<base_alloc_type>;
- using list_type = typename boost::intrusive::make_list<element,
- boost::intrusive::constant_time_size<true>>::type;
+ beast::detail::allocator_traits<rebind_type>;
+
+ using list_type = typename boost::intrusive::make_list<
+ element, boost::intrusive::constant_time_size<true>>::type;
+
using iter = typename list_type::iterator;
- using const_iter = typename list_type::const_iterator;
- using size_type = typename alloc_traits::size_type;
+ using const_iter = typename list_type::const_iterator;
using pocma = typename
alloc_traits::propagate_on_container_move_assignment;
diff --git a/boost/beast/core/rate_policy.hpp b/boost/beast/core/rate_policy.hpp
index 1f8abb9b6a..6375b11811 100644
--- a/boost/beast/core/rate_policy.hpp
+++ b/boost/beast/core/rate_policy.hpp
@@ -152,7 +152,7 @@ class simple_rate_policy
friend class rate_policy_access;
static std::size_t constexpr all =
- std::numeric_limits<std::size_t>::max();
+ (std::numeric_limits<std::size_t>::max)();
std::size_t rd_remain_ = all;
std::size_t wr_remain_ = all;
diff --git a/boost/beast/core/span.hpp b/boost/beast/core/span.hpp
index e170729472..55a1454efd 100644
--- a/boost/beast/core/span.hpp
+++ b/boost/beast/core/span.hpp
@@ -186,21 +186,21 @@ public:
{
return data_;
}
-
+
/// Returns an iterator to the beginning of the span
const_iterator
cbegin() const
{
return data_;
}
-
+
/// Returns an iterator to one past the end of the span
const_iterator
end() const
{
return data_ + size_;
}
-
+
/// Returns an iterator to one past the end of the span
const_iterator
cend() const
diff --git a/boost/beast/core/static_buffer.hpp b/boost/beast/core/static_buffer.hpp
index 1e44237164..c4ff534f56 100644
--- a/boost/beast/core/static_buffer.hpp
+++ b/boost/beast/core/static_buffer.hpp
@@ -13,11 +13,7 @@
#include <boost/beast/core/detail/config.hpp>
#include <boost/beast/core/detail/buffers_pair.hpp>
#include <boost/asio/buffer.hpp>
-#include <boost/assert.hpp>
-#include <algorithm>
-#include <array>
#include <cstddef>
-#include <cstring>
namespace boost {
namespace beast {
@@ -134,7 +130,7 @@ public:
BOOST_BEAST_DECL
const_buffers_type
data() const noexcept;
-
+
/// Returns a constant buffer sequence representing the readable bytes
const_buffers_type
cdata() const noexcept
@@ -148,7 +144,7 @@ public:
data() noexcept;
/** Returns a mutable buffer sequence representing writable bytes.
-
+
Returns a mutable buffer sequence representing the writable
bytes containing exactly `n` bytes of storage. Memory may be
reallocated as needed.
diff --git a/boost/beast/core/static_string.hpp b/boost/beast/core/static_string.hpp
index fc60a72e7d..c1cea6c36e 100644
--- a/boost/beast/core/static_string.hpp
+++ b/boost/beast/core/static_string.hpp
@@ -16,8 +16,7 @@
#include <algorithm>
#include <cstdint>
#include <initializer_list>
-#include <iterator>
-#include <ostream>
+#include <iosfwd>
#include <stdexcept>
#include <string>
#include <type_traits>
diff --git a/boost/beast/core/string.hpp b/boost/beast/core/string.hpp
index 976bfca48a..06edca1969 100644
--- a/boost/beast/core/string.hpp
+++ b/boost/beast/core/string.hpp
@@ -11,82 +11,11 @@
#define BOOST_BEAST_STRING_HPP
#include <boost/beast/core/detail/config.hpp>
-#include <boost/version.hpp>
-
-#if defined(BOOST_BEAST_USE_STD_STRING_VIEW)
-#include <string_view>
-#else
-#include <boost/utility/string_view.hpp>
-#endif
-
-#include <algorithm>
+#include <boost/beast/core/string_type.hpp>
namespace boost {
namespace beast {
-#if defined(BOOST_BEAST_USE_STD_STRING_VIEW)
- /// The type of string view used by the library
- using string_view = std::string_view;
-
- /// The type of basic string view used by the library
- template<class CharT, class Traits>
- using basic_string_view =
- std::basic_string_view<CharT, Traits>;
-#else
- /// The type of string view used by the library
- using string_view = boost::string_view;
-
- /// The type of basic string view used by the library
- template<class CharT, class Traits>
- using basic_string_view =
- boost::basic_string_view<CharT, Traits>;
-#endif
-
-namespace detail {
-
-inline
-char
-ascii_tolower(char c)
-{
- return ((static_cast<unsigned>(c) - 65U) < 26) ?
- c + 'a' - 'A' : c;
-}
-
-template<class = void>
-bool
-iequals(
- beast::string_view lhs,
- beast::string_view rhs)
-{
- auto n = lhs.size();
- if(rhs.size() != n)
- return false;
- auto p1 = lhs.data();
- auto p2 = rhs.data();
- char a, b;
- // fast loop
- while(n--)
- {
- a = *p1++;
- b = *p2++;
- if(a != b)
- goto slow;
- }
- return true;
-slow:
- do
- {
- if(ascii_tolower(a) != ascii_tolower(b))
- return false;
- a = *p1++;
- b = *p2++;
- }
- while(n--);
- return true;
-}
-
-} // detail
-
/** Returns `true` if two strings are equal, using a case-insensitive comparison.
The case-comparison operation is defined only for low-ASCII characters.
@@ -95,14 +24,11 @@ slow:
@param rhs The string on the right side of the equality
*/
-inline
+BOOST_BEAST_DECL
bool
iequals(
beast::string_view lhs,
- beast::string_view rhs)
-{
- return detail::iequals(lhs, rhs);
-}
+ beast::string_view rhs);
/** A case-insensitive less predicate for strings.
@@ -110,21 +36,11 @@ iequals(
*/
struct iless
{
+ BOOST_BEAST_DECL
bool
operator()(
string_view lhs,
- string_view rhs) const
- {
- using std::begin;
- using std::end;
- return std::lexicographical_compare(
- begin(lhs), end(lhs), begin(rhs), end(rhs),
- [](char c1, char c2)
- {
- return detail::ascii_tolower(c1) < detail::ascii_tolower(c2);
- }
- );
- }
+ string_view rhs) const;
};
/** A case-insensitive equality predicate for strings.
@@ -145,4 +61,8 @@ struct iequal
} // beast
} // boost
+#ifdef BOOST_BEAST_HEADER_ONLY
+#include <boost/beast/core/impl/string.ipp>
+#endif
+
#endif
diff --git a/boost/beast/core/string_param.hpp b/boost/beast/core/string_param.hpp
index 67ef69469c..cc55bfd170 100644
--- a/boost/beast/core/string_param.hpp
+++ b/boost/beast/core/string_param.hpp
@@ -14,7 +14,6 @@
#include <boost/beast/core/string.hpp>
#include <boost/beast/core/static_string.hpp>
#include <boost/beast/core/detail/static_ostream.hpp>
-#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/optional.hpp>
namespace boost {
diff --git a/boost/beast/core/string_type.hpp b/boost/beast/core/string_type.hpp
new file mode 100644
index 0000000000..b6b3f00534
--- /dev/null
+++ b/boost/beast/core/string_type.hpp
@@ -0,0 +1,45 @@
+//
+// Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com)
+//
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// Official repository: https://github.com/boostorg/beast
+//
+
+#ifndef BOOST_BEAST_STRING_TYPE_HPP
+#define BOOST_BEAST_STRING_TYPE_HPP
+
+#include <boost/beast/core/detail/config.hpp>
+
+#if defined(BOOST_BEAST_USE_STD_STRING_VIEW)
+#include <string_view>
+#else
+#include <boost/utility/string_view.hpp>
+#endif
+
+namespace boost {
+namespace beast {
+
+#if BOOST_BEAST_DOXYGEN || ! defined(BOOST_BEAST_USE_STD_STRING_VIEW)
+/// The type of string view used by the library
+using string_view = boost::string_view;
+
+/// The type of `basic_string_view` used by the library
+template<class CharT, class Traits>
+using basic_string_view =
+ boost::basic_string_view<CharT, Traits>;
+
+#else
+using string_view = std::string_view;
+
+template<class CharT, class Traits>
+using basic_string_view =
+ std::basic_string_view<CharT, Traits>;
+
+#endif
+
+} // beast
+} // boost
+
+#endif