update boost
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// buffer.hpp
|
||||
// ~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
// Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff 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)
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <boost/asio/detail/string_view.hpp>
|
||||
#include <boost/asio/detail/throw_exception.hpp>
|
||||
#include <boost/asio/detail/type_traits.hpp>
|
||||
#include <boost/asio/is_contiguous_iterator.hpp>
|
||||
|
||||
#if defined(BOOST_ASIO_MSVC) && (BOOST_ASIO_MSVC >= 1700)
|
||||
# if defined(_HAS_ITERATOR_DEBUGGING) && (_HAS_ITERATOR_DEBUGGING != 0)
|
||||
@@ -50,11 +51,13 @@
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_BOOST_WORKAROUND)
|
||||
# include <boost/detail/workaround.hpp>
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582)) \
|
||||
|| BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
|
||||
# if !defined(__clang__)
|
||||
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
# define BOOST_ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND
|
||||
# endif // BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
# elif BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
|
||||
# define BOOST_ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND
|
||||
# endif // BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
|
||||
// || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
|
||||
# endif // BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x590))
|
||||
#endif // defined(BOOST_ASIO_HAS_BOOST_WORKAROUND)
|
||||
|
||||
#if defined(BOOST_ASIO_ENABLE_ARRAY_BUFFER_WORKAROUND)
|
||||
@@ -385,9 +388,9 @@ private:
|
||||
/// Get an iterator to the first element in a buffer sequence.
|
||||
template <typename MutableBuffer>
|
||||
inline const mutable_buffer* buffer_sequence_begin(const MutableBuffer& b,
|
||||
typename enable_if<
|
||||
typename constraint<
|
||||
is_convertible<const MutableBuffer*, const mutable_buffer*>::value
|
||||
>::type* = 0) BOOST_ASIO_NOEXCEPT
|
||||
>::type = 0) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return static_cast<const mutable_buffer*>(detail::addressof(b));
|
||||
}
|
||||
@@ -395,9 +398,9 @@ inline const mutable_buffer* buffer_sequence_begin(const MutableBuffer& b,
|
||||
/// Get an iterator to the first element in a buffer sequence.
|
||||
template <typename ConstBuffer>
|
||||
inline const const_buffer* buffer_sequence_begin(const ConstBuffer& b,
|
||||
typename enable_if<
|
||||
typename constraint<
|
||||
is_convertible<const ConstBuffer*, const const_buffer*>::value
|
||||
>::type* = 0) BOOST_ASIO_NOEXCEPT
|
||||
>::type = 0) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return static_cast<const const_buffer*>(detail::addressof(b));
|
||||
}
|
||||
@@ -407,10 +410,10 @@ inline const const_buffer* buffer_sequence_begin(const ConstBuffer& b,
|
||||
/// Get an iterator to the first element in a buffer sequence.
|
||||
template <typename C>
|
||||
inline auto buffer_sequence_begin(C& c,
|
||||
typename enable_if<
|
||||
typename constraint<
|
||||
!is_convertible<const C*, const mutable_buffer*>::value
|
||||
&& !is_convertible<const C*, const const_buffer*>::value
|
||||
>::type* = 0) BOOST_ASIO_NOEXCEPT -> decltype(c.begin())
|
||||
>::type = 0) BOOST_ASIO_NOEXCEPT -> decltype(c.begin())
|
||||
{
|
||||
return c.begin();
|
||||
}
|
||||
@@ -418,10 +421,10 @@ inline auto buffer_sequence_begin(C& c,
|
||||
/// Get an iterator to the first element in a buffer sequence.
|
||||
template <typename C>
|
||||
inline auto buffer_sequence_begin(const C& c,
|
||||
typename enable_if<
|
||||
typename constraint<
|
||||
!is_convertible<const C*, const mutable_buffer*>::value
|
||||
&& !is_convertible<const C*, const const_buffer*>::value
|
||||
>::type* = 0) BOOST_ASIO_NOEXCEPT -> decltype(c.begin())
|
||||
>::type = 0) BOOST_ASIO_NOEXCEPT -> decltype(c.begin())
|
||||
{
|
||||
return c.begin();
|
||||
}
|
||||
@@ -430,20 +433,20 @@ inline auto buffer_sequence_begin(const C& c,
|
||||
|
||||
template <typename C>
|
||||
inline typename C::iterator buffer_sequence_begin(C& c,
|
||||
typename enable_if<
|
||||
typename constraint<
|
||||
!is_convertible<const C*, const mutable_buffer*>::value
|
||||
&& !is_convertible<const C*, const const_buffer*>::value
|
||||
>::type* = 0) BOOST_ASIO_NOEXCEPT
|
||||
>::type = 0) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return c.begin();
|
||||
}
|
||||
|
||||
template <typename C>
|
||||
inline typename C::const_iterator buffer_sequence_begin(const C& c,
|
||||
typename enable_if<
|
||||
typename constraint<
|
||||
!is_convertible<const C*, const mutable_buffer*>::value
|
||||
&& !is_convertible<const C*, const const_buffer*>::value
|
||||
>::type* = 0) BOOST_ASIO_NOEXCEPT
|
||||
>::type = 0) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return c.begin();
|
||||
}
|
||||
@@ -462,9 +465,9 @@ inline typename C::const_iterator buffer_sequence_begin(const C& c,
|
||||
/// Get an iterator to one past the end element in a buffer sequence.
|
||||
template <typename MutableBuffer>
|
||||
inline const mutable_buffer* buffer_sequence_end(const MutableBuffer& b,
|
||||
typename enable_if<
|
||||
typename constraint<
|
||||
is_convertible<const MutableBuffer*, const mutable_buffer*>::value
|
||||
>::type* = 0) BOOST_ASIO_NOEXCEPT
|
||||
>::type = 0) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return static_cast<const mutable_buffer*>(detail::addressof(b)) + 1;
|
||||
}
|
||||
@@ -472,9 +475,9 @@ inline const mutable_buffer* buffer_sequence_end(const MutableBuffer& b,
|
||||
/// Get an iterator to one past the end element in a buffer sequence.
|
||||
template <typename ConstBuffer>
|
||||
inline const const_buffer* buffer_sequence_end(const ConstBuffer& b,
|
||||
typename enable_if<
|
||||
typename constraint<
|
||||
is_convertible<const ConstBuffer*, const const_buffer*>::value
|
||||
>::type* = 0) BOOST_ASIO_NOEXCEPT
|
||||
>::type = 0) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return static_cast<const const_buffer*>(detail::addressof(b)) + 1;
|
||||
}
|
||||
@@ -484,10 +487,10 @@ inline const const_buffer* buffer_sequence_end(const ConstBuffer& b,
|
||||
/// Get an iterator to one past the end element in a buffer sequence.
|
||||
template <typename C>
|
||||
inline auto buffer_sequence_end(C& c,
|
||||
typename enable_if<
|
||||
typename constraint<
|
||||
!is_convertible<const C*, const mutable_buffer*>::value
|
||||
&& !is_convertible<const C*, const const_buffer*>::value
|
||||
>::type* = 0) BOOST_ASIO_NOEXCEPT -> decltype(c.end())
|
||||
>::type = 0) BOOST_ASIO_NOEXCEPT -> decltype(c.end())
|
||||
{
|
||||
return c.end();
|
||||
}
|
||||
@@ -495,10 +498,10 @@ inline auto buffer_sequence_end(C& c,
|
||||
/// Get an iterator to one past the end element in a buffer sequence.
|
||||
template <typename C>
|
||||
inline auto buffer_sequence_end(const C& c,
|
||||
typename enable_if<
|
||||
typename constraint<
|
||||
!is_convertible<const C*, const mutable_buffer*>::value
|
||||
&& !is_convertible<const C*, const const_buffer*>::value
|
||||
>::type* = 0) BOOST_ASIO_NOEXCEPT -> decltype(c.end())
|
||||
>::type = 0) BOOST_ASIO_NOEXCEPT -> decltype(c.end())
|
||||
{
|
||||
return c.end();
|
||||
}
|
||||
@@ -507,20 +510,20 @@ inline auto buffer_sequence_end(const C& c,
|
||||
|
||||
template <typename C>
|
||||
inline typename C::iterator buffer_sequence_end(C& c,
|
||||
typename enable_if<
|
||||
typename constraint<
|
||||
!is_convertible<const C*, const mutable_buffer*>::value
|
||||
&& !is_convertible<const C*, const const_buffer*>::value
|
||||
>::type* = 0) BOOST_ASIO_NOEXCEPT
|
||||
>::type = 0) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return c.end();
|
||||
}
|
||||
|
||||
template <typename C>
|
||||
inline typename C::const_iterator buffer_sequence_end(const C& c,
|
||||
typename enable_if<
|
||||
typename constraint<
|
||||
!is_convertible<const C*, const mutable_buffer*>::value
|
||||
&& !is_convertible<const C*, const const_buffer*>::value
|
||||
>::type* = 0) BOOST_ASIO_NOEXCEPT
|
||||
>::type = 0) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return c.end();
|
||||
}
|
||||
@@ -890,6 +893,25 @@ private:
|
||||
* bufs2.push_back(boost::asio::buffer(d2));
|
||||
* bufs2.push_back(boost::asio::buffer(d3));
|
||||
* bytes_transferred = sock.send(bufs2); @endcode
|
||||
*
|
||||
* @par Buffer Literals
|
||||
*
|
||||
* The `_buf` literal suffix, defined in namespace
|
||||
* <tt>boost::asio::buffer_literals</tt>, may be used to create @c const_buffer
|
||||
* objects from string, binary integer, and hexadecimal integer literals.
|
||||
* For example:
|
||||
*
|
||||
* @code
|
||||
* using namespace boost::asio::buffer_literals;
|
||||
*
|
||||
* boost::asio::const_buffer b1 = "hello"_buf;
|
||||
* boost::asio::const_buffer b2 = 0xdeadbeef_buf;
|
||||
* boost::asio::const_buffer b3 = 0x0123456789abcdef0123456789abcdef_buf;
|
||||
* boost::asio::const_buffer b4 = 0b1010101011001100_buf; @endcode
|
||||
*
|
||||
* Note that the memory associated with a buffer literal is valid for the
|
||||
* lifetime of the program. This means that the buffer can be safely used with
|
||||
* asynchronous operations.
|
||||
*/
|
||||
/*@{*/
|
||||
|
||||
@@ -905,7 +927,7 @@ private:
|
||||
/**
|
||||
* @returns <tt>mutable_buffer(b)</tt>.
|
||||
*/
|
||||
inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
const mutable_buffer& b) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_MUTABLE_BUFFER(b);
|
||||
@@ -918,7 +940,8 @@ inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
* b.data(),
|
||||
* min(b.size(), max_size_in_bytes)); @endcode
|
||||
*/
|
||||
inline BOOST_ASIO_MUTABLE_BUFFER buffer(const mutable_buffer& b,
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
const mutable_buffer& b,
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_MUTABLE_BUFFER(
|
||||
@@ -935,7 +958,7 @@ inline BOOST_ASIO_MUTABLE_BUFFER buffer(const mutable_buffer& b,
|
||||
/**
|
||||
* @returns <tt>const_buffer(b)</tt>.
|
||||
*/
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const const_buffer& b) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(b);
|
||||
@@ -948,7 +971,8 @@ inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
* b.data(),
|
||||
* min(b.size(), max_size_in_bytes)); @endcode
|
||||
*/
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(const const_buffer& b,
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const const_buffer& b,
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(b.data(),
|
||||
@@ -964,8 +988,8 @@ inline BOOST_ASIO_CONST_BUFFER buffer(const const_buffer& b,
|
||||
/**
|
||||
* @returns <tt>mutable_buffer(data, size_in_bytes)</tt>.
|
||||
*/
|
||||
inline BOOST_ASIO_MUTABLE_BUFFER buffer(void* data,
|
||||
std::size_t size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
void* data, std::size_t size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_MUTABLE_BUFFER(data, size_in_bytes);
|
||||
}
|
||||
@@ -974,8 +998,8 @@ inline BOOST_ASIO_MUTABLE_BUFFER buffer(void* data,
|
||||
/**
|
||||
* @returns <tt>const_buffer(data, size_in_bytes)</tt>.
|
||||
*/
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(const void* data,
|
||||
std::size_t size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const void* data, std::size_t size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(data, size_in_bytes);
|
||||
}
|
||||
@@ -988,7 +1012,8 @@ inline BOOST_ASIO_CONST_BUFFER buffer(const void* data,
|
||||
* N * sizeof(PodType)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_MUTABLE_BUFFER buffer(PodType (&data)[N]) BOOST_ASIO_NOEXCEPT
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
PodType (&data)[N]) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_MUTABLE_BUFFER(data, N * sizeof(PodType));
|
||||
}
|
||||
@@ -1001,7 +1026,8 @@ inline BOOST_ASIO_MUTABLE_BUFFER buffer(PodType (&data)[N]) BOOST_ASIO_NOEXCEPT
|
||||
* min(N * sizeof(PodType), max_size_in_bytes)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_MUTABLE_BUFFER buffer(PodType (&data)[N],
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
PodType (&data)[N],
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_MUTABLE_BUFFER(data,
|
||||
@@ -1017,7 +1043,7 @@ inline BOOST_ASIO_MUTABLE_BUFFER buffer(PodType (&data)[N],
|
||||
* N * sizeof(PodType)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const PodType (&data)[N]) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(data, N * sizeof(PodType));
|
||||
@@ -1031,7 +1057,8 @@ inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
* min(N * sizeof(PodType), max_size_in_bytes)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(const PodType (&data)[N],
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const PodType (&data)[N],
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(data,
|
||||
@@ -1081,7 +1108,8 @@ struct buffer_types
|
||||
} // namespace detail
|
||||
|
||||
template <typename PodType, std::size_t N>
|
||||
inline typename detail::buffer_types<PodType>::container_type
|
||||
BOOST_ASIO_NODISCARD inline
|
||||
typename detail::buffer_types<PodType>::container_type
|
||||
buffer(boost::array<PodType, N>& data) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
typedef typename boost::asio::detail::buffer_types<PodType>::buffer_type
|
||||
@@ -1093,7 +1121,8 @@ buffer(boost::array<PodType, N>& data) BOOST_ASIO_NOEXCEPT
|
||||
}
|
||||
|
||||
template <typename PodType, std::size_t N>
|
||||
inline typename detail::buffer_types<PodType>::container_type
|
||||
BOOST_ASIO_NODISCARD inline
|
||||
typename detail::buffer_types<PodType>::container_type
|
||||
buffer(boost::array<PodType, N>& data,
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
@@ -1117,7 +1146,7 @@ buffer(boost::array<PodType, N>& data,
|
||||
* data.size() * sizeof(PodType)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
boost::array<PodType, N>& data) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_MUTABLE_BUFFER(
|
||||
@@ -1132,7 +1161,8 @@ inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
* min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_MUTABLE_BUFFER buffer(boost::array<PodType, N>& data,
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
boost::array<PodType, N>& data,
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_MUTABLE_BUFFER(data.c_array(),
|
||||
@@ -1148,7 +1178,7 @@ inline BOOST_ASIO_MUTABLE_BUFFER buffer(boost::array<PodType, N>& data,
|
||||
* data.size() * sizeof(PodType)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
boost::array<const PodType, N>& data) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(data.data(), data.size() * sizeof(PodType));
|
||||
@@ -1162,7 +1192,8 @@ inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
* min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(boost::array<const PodType, N>& data,
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
boost::array<const PodType, N>& data,
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(data.data(),
|
||||
@@ -1180,7 +1211,7 @@ inline BOOST_ASIO_CONST_BUFFER buffer(boost::array<const PodType, N>& data,
|
||||
* data.size() * sizeof(PodType)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const boost::array<PodType, N>& data) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(data.data(), data.size() * sizeof(PodType));
|
||||
@@ -1194,7 +1225,8 @@ inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
* min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(const boost::array<PodType, N>& data,
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const boost::array<PodType, N>& data,
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(data.data(),
|
||||
@@ -1212,7 +1244,7 @@ inline BOOST_ASIO_CONST_BUFFER buffer(const boost::array<PodType, N>& data,
|
||||
* data.size() * sizeof(PodType)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
std::array<PodType, N>& data) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_MUTABLE_BUFFER(data.data(), data.size() * sizeof(PodType));
|
||||
@@ -1226,7 +1258,8 @@ inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
* min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_MUTABLE_BUFFER buffer(std::array<PodType, N>& data,
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
std::array<PodType, N>& data,
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_MUTABLE_BUFFER(data.data(),
|
||||
@@ -1242,7 +1275,7 @@ inline BOOST_ASIO_MUTABLE_BUFFER buffer(std::array<PodType, N>& data,
|
||||
* data.size() * sizeof(PodType)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
std::array<const PodType, N>& data) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(data.data(), data.size() * sizeof(PodType));
|
||||
@@ -1256,7 +1289,8 @@ inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
* min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(std::array<const PodType, N>& data,
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
std::array<const PodType, N>& data,
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(data.data(),
|
||||
@@ -1272,7 +1306,7 @@ inline BOOST_ASIO_CONST_BUFFER buffer(std::array<const PodType, N>& data,
|
||||
* data.size() * sizeof(PodType)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const std::array<PodType, N>& data) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(data.data(), data.size() * sizeof(PodType));
|
||||
@@ -1286,7 +1320,8 @@ inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
* min(data.size() * sizeof(PodType), max_size_in_bytes)); @endcode
|
||||
*/
|
||||
template <typename PodType, std::size_t N>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(const std::array<PodType, N>& data,
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const std::array<PodType, N>& data,
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(data.data(),
|
||||
@@ -1307,7 +1342,7 @@ inline BOOST_ASIO_CONST_BUFFER buffer(const std::array<PodType, N>& data,
|
||||
* invalidate iterators.
|
||||
*/
|
||||
template <typename PodType, typename Allocator>
|
||||
inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
std::vector<PodType, Allocator>& data) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_MUTABLE_BUFFER(
|
||||
@@ -1331,7 +1366,8 @@ inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
* invalidate iterators.
|
||||
*/
|
||||
template <typename PodType, typename Allocator>
|
||||
inline BOOST_ASIO_MUTABLE_BUFFER buffer(std::vector<PodType, Allocator>& data,
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
std::vector<PodType, Allocator>& data,
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_MUTABLE_BUFFER(data.size() ? &data[0] : 0,
|
||||
@@ -1356,7 +1392,7 @@ inline BOOST_ASIO_MUTABLE_BUFFER buffer(std::vector<PodType, Allocator>& data,
|
||||
* invalidate iterators.
|
||||
*/
|
||||
template <typename PodType, typename Allocator>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const std::vector<PodType, Allocator>& data) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(
|
||||
@@ -1380,7 +1416,7 @@ inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
* invalidate iterators.
|
||||
*/
|
||||
template <typename PodType, typename Allocator>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const std::vector<PodType, Allocator>& data,
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
@@ -1404,7 +1440,7 @@ inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
* given string object.
|
||||
*/
|
||||
template <typename Elem, typename Traits, typename Allocator>
|
||||
inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
std::basic_string<Elem, Traits, Allocator>& data) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_MUTABLE_BUFFER(data.size() ? &data[0] : 0,
|
||||
@@ -1428,7 +1464,7 @@ inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
* given string object.
|
||||
*/
|
||||
template <typename Elem, typename Traits, typename Allocator>
|
||||
inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
std::basic_string<Elem, Traits, Allocator>& data,
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
@@ -1451,7 +1487,7 @@ inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
* given string object.
|
||||
*/
|
||||
template <typename Elem, typename Traits, typename Allocator>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const std::basic_string<Elem, Traits, Allocator>& data) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(data.data(), data.size() * sizeof(Elem)
|
||||
@@ -1474,7 +1510,7 @@ inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
* given string object.
|
||||
*/
|
||||
template <typename Elem, typename Traits, typename Allocator>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const std::basic_string<Elem, Traits, Allocator>& data,
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
@@ -1492,13 +1528,13 @@ inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
#if defined(BOOST_ASIO_HAS_STRING_VIEW) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Create a new modifiable buffer that represents the given string_view.
|
||||
/// Create a new non-modifiable buffer that represents the given string_view.
|
||||
/**
|
||||
* @returns <tt>mutable_buffer(data.size() ? &data[0] : 0,
|
||||
* data.size() * sizeof(Elem))</tt>.
|
||||
*/
|
||||
template <typename Elem, typename Traits>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
basic_string_view<Elem, Traits> data) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(data.size() ? &data[0] : 0,
|
||||
@@ -1519,7 +1555,7 @@ inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
* min(data.size() * sizeof(Elem), max_size_in_bytes)); @endcode
|
||||
*/
|
||||
template <typename Elem, typename Traits>
|
||||
inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
basic_string_view<Elem, Traits> data,
|
||||
std::size_t max_size_in_bytes) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
@@ -1537,6 +1573,215 @@ inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
#endif // defined(BOOST_ASIO_HAS_STRING_VIEW)
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
/// Create a new modifiable buffer from a contiguous container.
|
||||
/**
|
||||
* @returns A mutable_buffer value equivalent to:
|
||||
* @code mutable_buffer(
|
||||
* data.size() ? &data[0] : 0,
|
||||
* data.size() * sizeof(typename T::value_type)); @endcode
|
||||
*/
|
||||
template <typename T>
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
T& data,
|
||||
typename constraint<
|
||||
is_contiguous_iterator<typename T::iterator>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
!is_convertible<T, const_buffer>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
!is_convertible<T, mutable_buffer>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
!is_const<
|
||||
typename remove_reference<
|
||||
typename std::iterator_traits<typename T::iterator>::reference
|
||||
>::type
|
||||
>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_MUTABLE_BUFFER(
|
||||
data.size() ? detail::to_address(data.begin()) : 0,
|
||||
data.size() * sizeof(typename T::value_type));
|
||||
}
|
||||
|
||||
/// Create a new modifiable buffer from a contiguous container.
|
||||
/**
|
||||
* @returns A mutable_buffer value equivalent to:
|
||||
* @code mutable_buffer(
|
||||
* data.size() ? &data[0] : 0,
|
||||
* min(
|
||||
* data.size() * sizeof(typename T::value_type),
|
||||
* max_size_in_bytes)); @endcode
|
||||
*/
|
||||
template <typename T>
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_MUTABLE_BUFFER buffer(
|
||||
T& data, std::size_t max_size_in_bytes,
|
||||
typename constraint<
|
||||
is_contiguous_iterator<typename T::iterator>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
!is_convertible<T, const_buffer>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
!is_convertible<T, mutable_buffer>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
!is_const<
|
||||
typename remove_reference<
|
||||
typename std::iterator_traits<typename T::iterator>::reference
|
||||
>::type
|
||||
>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_MUTABLE_BUFFER(
|
||||
data.size() ? detail::to_address(data.begin()) : 0,
|
||||
data.size() * sizeof(typename T::value_type) < max_size_in_bytes
|
||||
? data.size() * sizeof(typename T::value_type) : max_size_in_bytes);
|
||||
}
|
||||
|
||||
/// Create a new non-modifiable buffer from a contiguous container.
|
||||
/**
|
||||
* @returns A const_buffer value equivalent to:
|
||||
* @code const_buffer(
|
||||
* data.size() ? &data[0] : 0,
|
||||
* data.size() * sizeof(typename T::value_type)); @endcode
|
||||
*/
|
||||
template <typename T>
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
T& data,
|
||||
typename constraint<
|
||||
is_contiguous_iterator<typename T::iterator>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
!is_convertible<T, const_buffer>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
!is_convertible<T, mutable_buffer>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
is_const<
|
||||
typename remove_reference<
|
||||
typename std::iterator_traits<typename T::iterator>::reference
|
||||
>::type
|
||||
>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(
|
||||
data.size() ? detail::to_address(data.begin()) : 0,
|
||||
data.size() * sizeof(typename T::value_type));
|
||||
}
|
||||
|
||||
/// Create a new non-modifiable buffer from a contiguous container.
|
||||
/**
|
||||
* @returns A const_buffer value equivalent to:
|
||||
* @code const_buffer(
|
||||
* data.size() ? &data[0] : 0,
|
||||
* min(
|
||||
* data.size() * sizeof(typename T::value_type),
|
||||
* max_size_in_bytes)); @endcode
|
||||
*/
|
||||
template <typename T>
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
T& data, std::size_t max_size_in_bytes,
|
||||
typename constraint<
|
||||
is_contiguous_iterator<typename T::iterator>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
!is_convertible<T, const_buffer>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
!is_convertible<T, mutable_buffer>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
is_const<
|
||||
typename remove_reference<
|
||||
typename std::iterator_traits<typename T::iterator>::reference
|
||||
>::type
|
||||
>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(
|
||||
data.size() ? detail::to_address(data.begin()) : 0,
|
||||
data.size() * sizeof(typename T::value_type) < max_size_in_bytes
|
||||
? data.size() * sizeof(typename T::value_type) : max_size_in_bytes);
|
||||
}
|
||||
|
||||
/// Create a new non-modifiable buffer from a contiguous container.
|
||||
/**
|
||||
* @returns A const_buffer value equivalent to:
|
||||
* @code const_buffer(
|
||||
* data.size() ? &data[0] : 0,
|
||||
* data.size() * sizeof(typename T::value_type)); @endcode
|
||||
*/
|
||||
template <typename T>
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const T& data,
|
||||
typename constraint<
|
||||
is_contiguous_iterator<typename T::const_iterator>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
!is_convertible<T, const_buffer>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
!is_convertible<T, mutable_buffer>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(
|
||||
data.size() ? detail::to_address(data.begin()) : 0,
|
||||
data.size() * sizeof(typename T::value_type));
|
||||
}
|
||||
|
||||
/// Create a new non-modifiable buffer from a contiguous container.
|
||||
/**
|
||||
* @returns A const_buffer value equivalent to:
|
||||
* @code const_buffer(
|
||||
* data.size() ? &data[0] : 0,
|
||||
* min(
|
||||
* data.size() * sizeof(typename T::value_type),
|
||||
* max_size_in_bytes)); @endcode
|
||||
*/
|
||||
template <typename T>
|
||||
BOOST_ASIO_NODISCARD inline BOOST_ASIO_CONST_BUFFER buffer(
|
||||
const T& data, std::size_t max_size_in_bytes,
|
||||
typename constraint<
|
||||
is_contiguous_iterator<typename T::const_iterator>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
!is_convertible<T, const_buffer>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint(),
|
||||
typename constraint<
|
||||
!is_convertible<T, mutable_buffer>::value,
|
||||
defaulted_constraint
|
||||
>::type = defaulted_constraint()) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(
|
||||
data.size() ? detail::to_address(data.begin()) : 0,
|
||||
data.size() * sizeof(typename T::value_type) < max_size_in_bytes
|
||||
? data.size() * sizeof(typename T::value_type) : max_size_in_bytes);
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
/// Adapt a basic_string to the DynamicBuffer requirements.
|
||||
@@ -2095,7 +2340,8 @@ private:
|
||||
* @returns <tt>dynamic_string_buffer<Elem, Traits, Allocator>(data)</tt>.
|
||||
*/
|
||||
template <typename Elem, typename Traits, typename Allocator>
|
||||
inline dynamic_string_buffer<Elem, Traits, Allocator> dynamic_buffer(
|
||||
BOOST_ASIO_NODISCARD inline
|
||||
dynamic_string_buffer<Elem, Traits, Allocator> dynamic_buffer(
|
||||
std::basic_string<Elem, Traits, Allocator>& data) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return dynamic_string_buffer<Elem, Traits, Allocator>(data);
|
||||
@@ -2107,7 +2353,8 @@ inline dynamic_string_buffer<Elem, Traits, Allocator> dynamic_buffer(
|
||||
* max_size)</tt>.
|
||||
*/
|
||||
template <typename Elem, typename Traits, typename Allocator>
|
||||
inline dynamic_string_buffer<Elem, Traits, Allocator> dynamic_buffer(
|
||||
BOOST_ASIO_NODISCARD inline
|
||||
dynamic_string_buffer<Elem, Traits, Allocator> dynamic_buffer(
|
||||
std::basic_string<Elem, Traits, Allocator>& data,
|
||||
std::size_t max_size) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
@@ -2119,7 +2366,8 @@ inline dynamic_string_buffer<Elem, Traits, Allocator> dynamic_buffer(
|
||||
* @returns <tt>dynamic_vector_buffer<Elem, Allocator>(data)</tt>.
|
||||
*/
|
||||
template <typename Elem, typename Allocator>
|
||||
inline dynamic_vector_buffer<Elem, Allocator> dynamic_buffer(
|
||||
BOOST_ASIO_NODISCARD inline
|
||||
dynamic_vector_buffer<Elem, Allocator> dynamic_buffer(
|
||||
std::vector<Elem, Allocator>& data) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
return dynamic_vector_buffer<Elem, Allocator>(data);
|
||||
@@ -2130,7 +2378,8 @@ inline dynamic_vector_buffer<Elem, Allocator> dynamic_buffer(
|
||||
* @returns <tt>dynamic_vector_buffer<Elem, Allocator>(data, max_size)</tt>.
|
||||
*/
|
||||
template <typename Elem, typename Allocator>
|
||||
inline dynamic_vector_buffer<Elem, Allocator> dynamic_buffer(
|
||||
BOOST_ASIO_NODISCARD inline
|
||||
dynamic_vector_buffer<Elem, Allocator> dynamic_buffer(
|
||||
std::vector<Elem, Allocator>& data,
|
||||
std::size_t max_size) BOOST_ASIO_NOEXCEPT
|
||||
{
|
||||
@@ -2476,7 +2725,7 @@ struct is_dynamic_buffer_v2
|
||||
* If @c BOOST_ASIO_NO_DYNAMIC_BUFFER_V1 is not defined, determines whether the
|
||||
* type satisfies the DynamicBuffer_v1 requirements. Otherwise, if @c
|
||||
* BOOST_ASIO_NO_DYNAMIC_BUFFER_V1 is defined, determines whether the type
|
||||
* satisfies the DynamicBuffer_v1 requirements.
|
||||
* satisfies the DynamicBuffer_v2 requirements.
|
||||
*/
|
||||
template <typename T>
|
||||
struct is_dynamic_buffer
|
||||
@@ -2490,6 +2739,172 @@ struct is_dynamic_buffer
|
||||
{
|
||||
};
|
||||
|
||||
#if (defined(BOOST_ASIO_HAS_USER_DEFINED_LITERALS) \
|
||||
&& defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES)) \
|
||||
|| defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
namespace buffer_literals {
|
||||
namespace detail {
|
||||
|
||||
template <char... Chars>
|
||||
struct chars {};
|
||||
|
||||
template <unsigned char... Bytes>
|
||||
struct bytes {};
|
||||
|
||||
// Literal processor that converts binary literals to an array of bytes.
|
||||
|
||||
template <typename Bytes, char... Chars>
|
||||
struct bin_literal;
|
||||
|
||||
template <unsigned char... Bytes>
|
||||
struct bin_literal<bytes<Bytes...> >
|
||||
{
|
||||
static const std::size_t size = sizeof...(Bytes);
|
||||
static const unsigned char data[sizeof...(Bytes)];
|
||||
};
|
||||
|
||||
template <unsigned char... Bytes>
|
||||
const unsigned char bin_literal<bytes<Bytes...> >::data[sizeof...(Bytes)]
|
||||
= { Bytes... };
|
||||
|
||||
template <unsigned char... Bytes, char Bit7, char Bit6, char Bit5,
|
||||
char Bit4, char Bit3, char Bit2, char Bit1, char Bit0, char... Chars>
|
||||
struct bin_literal<bytes<Bytes...>, Bit7, Bit6,
|
||||
Bit5, Bit4, Bit3, Bit2, Bit1, Bit0, Chars...> :
|
||||
bin_literal<
|
||||
bytes<Bytes...,
|
||||
static_cast<unsigned char>(
|
||||
(Bit7 == '1' ? 0x80 : 0) |
|
||||
(Bit6 == '1' ? 0x40 : 0) |
|
||||
(Bit5 == '1' ? 0x20 : 0) |
|
||||
(Bit4 == '1' ? 0x10 : 0) |
|
||||
(Bit3 == '1' ? 0x08 : 0) |
|
||||
(Bit2 == '1' ? 0x04 : 0) |
|
||||
(Bit1 == '1' ? 0x02 : 0) |
|
||||
(Bit0 == '1' ? 0x01 : 0))
|
||||
>, Chars...> {};
|
||||
|
||||
template <unsigned char... Bytes, char... Chars>
|
||||
struct bin_literal<bytes<Bytes...>, Chars...>
|
||||
{
|
||||
static_assert(sizeof...(Chars) == 0,
|
||||
"number of digits in a binary buffer literal must be a multiple of 8");
|
||||
|
||||
static const std::size_t size = 0;
|
||||
static const unsigned char data[1];
|
||||
};
|
||||
|
||||
template <unsigned char... Bytes, char... Chars>
|
||||
const unsigned char bin_literal<bytes<Bytes...>, Chars...>::data[1] = {};
|
||||
|
||||
// Literal processor that converts hexadecimal literals to an array of bytes.
|
||||
|
||||
template <typename Bytes, char... Chars>
|
||||
struct hex_literal;
|
||||
|
||||
template <unsigned char... Bytes>
|
||||
struct hex_literal<bytes<Bytes...> >
|
||||
{
|
||||
static const std::size_t size = sizeof...(Bytes);
|
||||
static const unsigned char data[sizeof...(Bytes)];
|
||||
};
|
||||
|
||||
template <unsigned char... Bytes>
|
||||
const unsigned char hex_literal<bytes<Bytes...> >::data[sizeof...(Bytes)]
|
||||
= { Bytes... };
|
||||
|
||||
template <unsigned char... Bytes, char Hi, char Lo, char... Chars>
|
||||
struct hex_literal<bytes<Bytes...>, Hi, Lo, Chars...> :
|
||||
hex_literal<
|
||||
bytes<Bytes...,
|
||||
static_cast<unsigned char>(
|
||||
Lo >= 'A' && Lo <= 'F' ? Lo - 'A' + 10 :
|
||||
(Lo >= 'a' && Lo <= 'f' ? Lo - 'a' + 10 : Lo - '0')) |
|
||||
((static_cast<unsigned char>(
|
||||
Hi >= 'A' && Hi <= 'F' ? Hi - 'A' + 10 :
|
||||
(Hi >= 'a' && Hi <= 'f' ? Hi - 'a' + 10 : Hi - '0'))) << 4)
|
||||
>, Chars...> {};
|
||||
|
||||
template <unsigned char... Bytes, char Char>
|
||||
struct hex_literal<bytes<Bytes...>, Char>
|
||||
{
|
||||
static_assert(!Char,
|
||||
"a hexadecimal buffer literal must have an even number of digits");
|
||||
|
||||
static const std::size_t size = 0;
|
||||
static const unsigned char data[1];
|
||||
};
|
||||
|
||||
template <unsigned char... Bytes, char Char>
|
||||
const unsigned char hex_literal<bytes<Bytes...>, Char>::data[1] = {};
|
||||
|
||||
// Helper template that removes digit separators and then passes the cleaned
|
||||
// variadic pack of characters to the literal processor.
|
||||
|
||||
template <template <typename, char...> class Literal,
|
||||
typename Clean, char... Raw>
|
||||
struct remove_separators;
|
||||
|
||||
template <template <typename, char...> class Literal,
|
||||
char... Clean, char... Raw>
|
||||
struct remove_separators<Literal, chars<Clean...>, '\'', Raw...> :
|
||||
remove_separators<Literal, chars<Clean...>, Raw...> {};
|
||||
|
||||
template <template <typename, char...> class Literal,
|
||||
char... Clean, char C, char... Raw>
|
||||
struct remove_separators<Literal, chars<Clean...>, C, Raw...> :
|
||||
remove_separators<Literal, chars<Clean..., C>, Raw...> {};
|
||||
|
||||
template <template <typename, char...> class Literal, char... Clean>
|
||||
struct remove_separators<Literal, chars<Clean...> > :
|
||||
Literal<bytes<>, Clean...> {};
|
||||
|
||||
// Helper template to determine the literal type based on the prefix.
|
||||
|
||||
template <char... Chars>
|
||||
struct literal;
|
||||
|
||||
template <char... Chars>
|
||||
struct literal<'0', 'b', Chars...> :
|
||||
remove_separators<bin_literal, chars<>, Chars...>{};
|
||||
|
||||
template <char... Chars>
|
||||
struct literal<'0', 'B', Chars...> :
|
||||
remove_separators<bin_literal, chars<>, Chars...>{};
|
||||
|
||||
template <char... Chars>
|
||||
struct literal<'0', 'x', Chars...> :
|
||||
remove_separators<hex_literal, chars<>, Chars...>{};
|
||||
|
||||
template <char... Chars>
|
||||
struct literal<'0', 'X', Chars...> :
|
||||
remove_separators<hex_literal, chars<>, Chars...>{};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
/// Literal operator for creating const_buffer objects from string literals.
|
||||
inline BOOST_ASIO_CONST_BUFFER operator"" _buf(const char* data, std::size_t n)
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(data, n);
|
||||
}
|
||||
|
||||
/// Literal operator for creating const_buffer objects from unbounded binary or
|
||||
/// hexadecimal integer literals.
|
||||
template <char... Chars>
|
||||
inline BOOST_ASIO_CONST_BUFFER operator"" _buf()
|
||||
{
|
||||
return BOOST_ASIO_CONST_BUFFER(
|
||||
+detail::literal<Chars...>::data,
|
||||
detail::literal<Chars...>::size);
|
||||
}
|
||||
|
||||
} // namespace buffer_literals
|
||||
|
||||
#endif // (defined(BOOST_ASIO_HAS_USER_DEFINED_LITERALS)
|
||||
// && defined(BOOST_ASIO_HAS_VARIADIC_TEMPLATES))
|
||||
// || defined(GENERATING_DOCUMENTATION)
|
||||
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
|
||||
Reference in New Issue
Block a user