mirror of
https://github.com/boostorg/beast.git
synced 2025-07-31 13:27:33 +02:00
Workarounds for msvc-14
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
Version 199:
|
||||||
|
|
||||||
|
* Workarounds for msvc-14
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Version 198:
|
Version 198:
|
||||||
|
|
||||||
* flat_buffer improvements
|
* flat_buffer improvements
|
||||||
|
3
Jamfile
3
Jamfile
@ -103,7 +103,8 @@ project /boost/beast
|
|||||||
<define>BOOST_ASIO_DISABLE_BOOST_DATE_TIME=1
|
<define>BOOST_ASIO_DISABLE_BOOST_DATE_TIME=1
|
||||||
<define>BOOST_ASIO_DISABLE_BOOST_REGEX=1
|
<define>BOOST_ASIO_DISABLE_BOOST_REGEX=1
|
||||||
<define>BOOST_COROUTINES_NO_DEPRECATION_WARNING=1
|
<define>BOOST_COROUTINES_NO_DEPRECATION_WARNING=1
|
||||||
<toolset>msvc:<cxxflags>"/bigobj /permissive-"
|
<toolset>msvc:<cxxflags>"/bigobj"
|
||||||
|
<toolset>msvc-14.1:<cxxflags>"/permissive-"
|
||||||
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS=1
|
<toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS=1
|
||||||
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS=1
|
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS=1
|
||||||
<toolset>msvc:<define>_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING
|
<toolset>msvc:<define>_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING
|
||||||
|
@ -12,58 +12,76 @@
|
|||||||
|
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
namespace beast {
|
namespace beast {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template<bool IsMutable>
|
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||||
|
# pragma warning (push)
|
||||||
|
# pragma warning (disable: 4521) // multiple copy constructors specified
|
||||||
|
# pragma warning (disable: 4522) // multiple assignment operators specified
|
||||||
|
#endif
|
||||||
|
|
||||||
|
template<bool isMutable>
|
||||||
class buffers_pair
|
class buffers_pair
|
||||||
{
|
{
|
||||||
template<bool IsMutable_>
|
|
||||||
friend class buffers_pair;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// VFALCO: This type is public otherwise
|
// VFALCO: This type is public otherwise
|
||||||
// asio::buffers_iterator won't compile.
|
// asio::buffers_iterator won't compile.
|
||||||
using value_type = typename
|
using value_type = typename
|
||||||
std::conditional<IsMutable,
|
std::conditional<isMutable,
|
||||||
net::mutable_buffer,
|
net::mutable_buffer,
|
||||||
net::const_buffer>::type;
|
net::const_buffer>::type;
|
||||||
|
|
||||||
using const_iterator = value_type const*;
|
using const_iterator = value_type const*;
|
||||||
|
|
||||||
buffers_pair() = default;
|
buffers_pair() = default;
|
||||||
buffers_pair(buffers_pair const&) = default;
|
#if defined(BOOST_MSVC) && BOOST_MSVC < 1910
|
||||||
buffers_pair& operator=(buffers_pair const&) = default;
|
buffers_pair(buffers_pair const& other)
|
||||||
|
: buffers_pair(
|
||||||
template<
|
*other.begin(), *(other.begin() + 1))
|
||||||
bool IsMutable_ = IsMutable,
|
|
||||||
class = typename
|
|
||||||
std::enable_if<! IsMutable_>::type>
|
|
||||||
buffers_pair(
|
|
||||||
buffers_pair<true> const& other) noexcept
|
|
||||||
: b_{other.b_[0], other.b_[1]}
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<
|
buffers_pair&
|
||||||
bool IsMutable_ = IsMutable,
|
operator=(buffers_pair const& other)
|
||||||
class = typename
|
|
||||||
std::enable_if<! IsMutable_>::type>
|
|
||||||
buffers_pair& operator=(
|
|
||||||
buffers_pair<true> const& other) noexcept
|
|
||||||
{
|
{
|
||||||
b_ = {other.b_[0], other.b_[1]};
|
b_[0] = *other.begin();
|
||||||
|
b_[1] = *(other.begin() + 1);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
buffers_pair(buffers_pair const& other) = default;
|
||||||
|
buffers_pair& operator=(buffers_pair const& other) = default;
|
||||||
|
#endif
|
||||||
|
|
||||||
value_type&
|
template<
|
||||||
operator[](int i) noexcept
|
bool isMutable_ = isMutable,
|
||||||
|
class = typename std::enable_if<
|
||||||
|
! isMutable_>::type>
|
||||||
|
buffers_pair(buffers_pair<true> const& other)
|
||||||
|
: buffers_pair(
|
||||||
|
*other.begin(), *(other.begin() + 1))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template<
|
||||||
|
bool isMutable_ = isMutable,
|
||||||
|
class = typename std::enable_if<
|
||||||
|
! isMutable_>::type>
|
||||||
|
buffers_pair&
|
||||||
|
operator=(buffers_pair<true> const& other)
|
||||||
|
{
|
||||||
|
b_[0] = *other.begin();
|
||||||
|
b_[1] = *(other.begin() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
buffers_pair(value_type b0, value_type b1)
|
||||||
|
: b_{b0, b1}
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(i >= 0 && i < 2);
|
|
||||||
return b_[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator
|
const_iterator
|
||||||
@ -79,10 +97,15 @@ public:
|
|||||||
return &b_[2];
|
return &b_[2];
|
||||||
return &b_[1];
|
return &b_[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
value_type b_[2];
|
value_type b_[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||||
|
# pragma warning (pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
} // detail
|
} // detail
|
||||||
} // beast
|
} // beast
|
||||||
} // boost
|
} // boost
|
||||||
|
@ -25,6 +25,27 @@ template<std::size_t I, class T>
|
|||||||
struct tuple_element_impl
|
struct tuple_element_impl
|
||||||
{
|
{
|
||||||
T t;
|
T t;
|
||||||
|
|
||||||
|
tuple_element_impl(T const& t_)
|
||||||
|
: t(t_)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
tuple_element_impl(T&& t_)
|
||||||
|
: t(std::move(t_))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<std::size_t I, class T>
|
||||||
|
struct tuple_element_impl<I, T&>
|
||||||
|
{
|
||||||
|
T& t;
|
||||||
|
|
||||||
|
tuple_element_impl(T& t_)
|
||||||
|
: t(t_)
|
||||||
|
{
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class... Ts>
|
template<class... Ts>
|
||||||
@ -32,12 +53,13 @@ struct tuple_impl;
|
|||||||
|
|
||||||
template<class... Ts, std::size_t... Is>
|
template<class... Ts, std::size_t... Is>
|
||||||
struct tuple_impl<
|
struct tuple_impl<
|
||||||
boost::mp11::index_sequence<Is...>, Ts...>
|
boost::mp11::index_sequence<Is...>, Ts...>
|
||||||
: tuple_element_impl<Is, Ts>...
|
: tuple_element_impl<Is, Ts>...
|
||||||
{
|
{
|
||||||
template<class... Us>
|
template<class... Us>
|
||||||
explicit tuple_impl(Us&&... us)
|
explicit tuple_impl(Us&&... us)
|
||||||
: tuple_element_impl<Is, Ts>{std::forward<Us>(us)}...
|
: tuple_element_impl<Is, Ts>(
|
||||||
|
std::forward<Us>(us))...
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -76,6 +98,13 @@ get(tuple_element_impl<I, T>&& te)
|
|||||||
return std::move(te.t);
|
return std::move(te.t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<std::size_t I, class T>
|
||||||
|
T&
|
||||||
|
get(tuple_element_impl<I, T&>&& te)
|
||||||
|
{
|
||||||
|
return te.t;
|
||||||
|
}
|
||||||
|
|
||||||
template <std::size_t I, class T>
|
template <std::size_t I, class T>
|
||||||
using tuple_element = typename boost::copy_cv<
|
using tuple_element = typename boost::copy_cv<
|
||||||
mp11::mp_at_c<typename remove_cv<T>::type, I>, T>::type;
|
mp11::mp_at_c<typename remove_cv<T>::type, I>, T>::type;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#define BOOST_BEAST_IMPL_MULTI_BUFFER_HPP
|
#define BOOST_BEAST_IMPL_MULTI_BUFFER_HPP
|
||||||
|
|
||||||
#include <boost/beast/core/detail/type_traits.hpp>
|
#include <boost/beast/core/detail/type_traits.hpp>
|
||||||
|
#include <boost/config/workaround.hpp>
|
||||||
#include <boost/core/exchange.hpp>
|
#include <boost/core/exchange.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
@ -125,6 +126,12 @@ public:
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||||
|
# pragma warning (push)
|
||||||
|
# pragma warning (disable: 4521) // multiple copy constructors specified
|
||||||
|
# pragma warning (disable: 4522) // multiple assignment operators specified
|
||||||
|
#endif
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
template<bool IsMutable>
|
template<bool IsMutable>
|
||||||
class basic_multi_buffer<Allocator>::readable_bytes
|
class basic_multi_buffer<Allocator>::readable_bytes
|
||||||
@ -149,8 +156,21 @@ public:
|
|||||||
class const_iterator;
|
class const_iterator;
|
||||||
|
|
||||||
readable_bytes() = delete;
|
readable_bytes() = delete;
|
||||||
|
#if ! defined(_MSC_VER) || (_MSC_VER >= 1910)
|
||||||
readable_bytes(readable_bytes const&) = default;
|
readable_bytes(readable_bytes const&) = default;
|
||||||
readable_bytes& operator=(readable_bytes const&) = default;
|
readable_bytes& operator=(readable_bytes const&) = default;
|
||||||
|
#else
|
||||||
|
readable_bytes(readable_bytes const& other)
|
||||||
|
: b_(other.b_)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
readable_bytes& operator=(readable_bytes const& other)
|
||||||
|
{
|
||||||
|
b_ = other.b_;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template<
|
template<
|
||||||
bool IsMutable_ = IsMutable,
|
bool IsMutable_ = IsMutable,
|
||||||
@ -182,6 +202,10 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||||
|
# pragma warning (pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
|
@ -34,19 +34,17 @@ static_buffer_base::
|
|||||||
data() const noexcept ->
|
data() const noexcept ->
|
||||||
const_buffers_type
|
const_buffers_type
|
||||||
{
|
{
|
||||||
using net::const_buffer;
|
|
||||||
const_buffers_type result;
|
|
||||||
if(in_off_ + in_size_ <= capacity_)
|
if(in_off_ + in_size_ <= capacity_)
|
||||||
{
|
return {
|
||||||
result[0] = const_buffer{begin_ + in_off_, in_size_};
|
net::const_buffer{
|
||||||
result[1] = const_buffer{begin_, 0};
|
begin_ + in_off_, in_size_},
|
||||||
}
|
net::const_buffer{
|
||||||
else
|
begin_, 0}};
|
||||||
{
|
return {
|
||||||
result[0] = const_buffer{begin_ + in_off_, capacity_ - in_off_};
|
net::const_buffer{
|
||||||
result[1] = const_buffer{begin_, in_size_ - (capacity_ - in_off_)};
|
begin_ + in_off_, capacity_ - in_off_},
|
||||||
}
|
net::const_buffer{
|
||||||
return result;
|
begin_, in_size_ - (capacity_ - in_off_)}};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto
|
auto
|
||||||
@ -54,19 +52,17 @@ static_buffer_base::
|
|||||||
data() noexcept ->
|
data() noexcept ->
|
||||||
mutable_data_type
|
mutable_data_type
|
||||||
{
|
{
|
||||||
using net::mutable_buffer;
|
|
||||||
mutable_data_type result;
|
|
||||||
if(in_off_ + in_size_ <= capacity_)
|
if(in_off_ + in_size_ <= capacity_)
|
||||||
{
|
return {
|
||||||
result[0] = mutable_buffer{begin_ + in_off_, in_size_};
|
net::mutable_buffer{
|
||||||
result[1] = mutable_buffer{begin_, 0};
|
begin_ + in_off_, in_size_},
|
||||||
}
|
net::mutable_buffer{
|
||||||
else
|
begin_, 0}};
|
||||||
{
|
return {
|
||||||
result[0] = mutable_buffer{begin_ + in_off_, capacity_ - in_off_};
|
net::mutable_buffer{
|
||||||
result[1] = mutable_buffer{begin_, in_size_ - (capacity_ - in_off_)};
|
begin_ + in_off_, capacity_ - in_off_},
|
||||||
}
|
net::mutable_buffer{
|
||||||
return result;
|
begin_, in_size_ - (capacity_ - in_off_)}};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto
|
auto
|
||||||
@ -79,19 +75,19 @@ prepare(std::size_t n) ->
|
|||||||
BOOST_THROW_EXCEPTION(std::length_error{
|
BOOST_THROW_EXCEPTION(std::length_error{
|
||||||
"buffer overflow"});
|
"buffer overflow"});
|
||||||
out_size_ = n;
|
out_size_ = n;
|
||||||
auto const out_off = (in_off_ + in_size_) % capacity_;
|
auto const out_off =
|
||||||
mutable_buffers_type result;
|
(in_off_ + in_size_) % capacity_;
|
||||||
if(out_off + out_size_ <= capacity_ )
|
if(out_off + out_size_ <= capacity_ )
|
||||||
{
|
return {
|
||||||
result[0] = mutable_buffer{begin_ + out_off, out_size_};
|
net::mutable_buffer{
|
||||||
result[1] = mutable_buffer{begin_, 0};
|
begin_ + out_off, out_size_},
|
||||||
}
|
net::mutable_buffer{
|
||||||
else
|
begin_, 0}};
|
||||||
{
|
return {
|
||||||
result[0] = mutable_buffer{begin_ + out_off, capacity_ - out_off};
|
net::mutable_buffer{
|
||||||
result[1] = mutable_buffer{begin_, out_size_ - (capacity_ - out_off)};
|
begin_ + out_off, capacity_ - out_off},
|
||||||
}
|
net::mutable_buffer{
|
||||||
return result;
|
begin_, out_size_ - (capacity_ - out_off)}};
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -46,7 +46,8 @@ public:
|
|||||||
BOOST_STATIC_ASSERT(std::is_convertible<
|
BOOST_STATIC_ASSERT(std::is_convertible<
|
||||||
multi_buffer::mutable_data_type,
|
multi_buffer::mutable_data_type,
|
||||||
multi_buffer::const_buffers_type>::value);
|
multi_buffer::const_buffers_type>::value);
|
||||||
#if ! defined( BOOST_LIBSTDCXX_VERSION ) || BOOST_LIBSTDCXX_VERSION >= 50000
|
#if ! BOOST_WORKAROUND(BOOST_LIBSTDCXX_VERSION, < 50000) && \
|
||||||
|
! BOOST_WORKAROUND(BOOST_MSVC, < 1910)
|
||||||
BOOST_STATIC_ASSERT(std::is_trivially_copyable<
|
BOOST_STATIC_ASSERT(std::is_trivially_copyable<
|
||||||
multi_buffer::const_buffers_type>::value);
|
multi_buffer::const_buffers_type>::value);
|
||||||
BOOST_STATIC_ASSERT(std::is_trivially_copyable<
|
BOOST_STATIC_ASSERT(std::is_trivially_copyable<
|
||||||
|
Reference in New Issue
Block a user