Workarounds for msvc-14

This commit is contained in:
Vinnie Falco
2018-12-13 16:43:17 -08:00
parent 926065d273
commit e17a92f2a8
7 changed files with 146 additions and 66 deletions

View File

@ -1,3 +1,9 @@
Version 199:
* Workarounds for msvc-14
--------------------------------------------------------------------------------
Version 198:
* flat_buffer improvements

View File

@ -103,7 +103,8 @@ project /boost/beast
<define>BOOST_ASIO_DISABLE_BOOST_DATE_TIME=1
<define>BOOST_ASIO_DISABLE_BOOST_REGEX=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>_CRT_SECURE_NO_WARNINGS=1
<toolset>msvc:<define>_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING

View File

@ -12,58 +12,76 @@
#include <boost/asio/buffer.hpp>
#include <boost/assert.hpp>
#include <boost/config/workaround.hpp>
#include <type_traits>
namespace boost {
namespace beast {
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
{
template<bool IsMutable_>
friend class buffers_pair;
public:
// VFALCO: This type is public otherwise
// asio::buffers_iterator won't compile.
using value_type = typename
std::conditional<IsMutable,
std::conditional<isMutable,
net::mutable_buffer,
net::const_buffer>::type;
using const_iterator = value_type const*;
buffers_pair() = default;
buffers_pair(buffers_pair const&) = default;
buffers_pair& operator=(buffers_pair const&) = default;
template<
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]}
#if defined(BOOST_MSVC) && BOOST_MSVC < 1910
buffers_pair(buffers_pair 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) noexcept
buffers_pair&
operator=(buffers_pair const& other)
{
b_ = {other.b_[0], other.b_[1]};
b_[0] = *other.begin();
b_[1] = *(other.begin() + 1);
return *this;
}
#else
buffers_pair(buffers_pair const& other) = default;
buffers_pair& operator=(buffers_pair const& other) = default;
#endif
value_type&
operator[](int i) noexcept
template<
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
@ -79,10 +97,15 @@ public:
return &b_[2];
return &b_[1];
}
private:
value_type b_[2];
};
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
# pragma warning (pop)
#endif
} // detail
} // beast
} // boost

View File

@ -25,6 +25,27 @@ template<std::size_t I, class T>
struct tuple_element_impl
{
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>
@ -32,12 +53,13 @@ struct tuple_impl;
template<class... Ts, std::size_t... Is>
struct tuple_impl<
boost::mp11::index_sequence<Is...>, Ts...>
boost::mp11::index_sequence<Is...>, Ts...>
: tuple_element_impl<Is, Ts>...
{
template<class... 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);
}
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>
using tuple_element = typename boost::copy_cv<
mp11::mp_at_c<typename remove_cv<T>::type, I>, T>::type;

View File

@ -11,6 +11,7 @@
#define BOOST_BEAST_IMPL_MULTI_BUFFER_HPP
#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/config/workaround.hpp>
#include <boost/core/exchange.hpp>
#include <boost/assert.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<bool IsMutable>
class basic_multi_buffer<Allocator>::readable_bytes
@ -149,8 +156,21 @@ public:
class const_iterator;
readable_bytes() = delete;
#if ! defined(_MSC_VER) || (_MSC_VER >= 1910)
readable_bytes(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<
bool IsMutable_ = IsMutable,
@ -182,6 +202,10 @@ public:
}
};
#if BOOST_WORKAROUND(BOOST_MSVC, < 1910)
# pragma warning (pop)
#endif
//------------------------------------------------------------------------------
template<class Allocator>

View File

@ -34,19 +34,17 @@ static_buffer_base::
data() const noexcept ->
const_buffers_type
{
using net::const_buffer;
const_buffers_type result;
if(in_off_ + in_size_ <= capacity_)
{
result[0] = const_buffer{begin_ + in_off_, in_size_};
result[1] = const_buffer{begin_, 0};
}
else
{
result[0] = const_buffer{begin_ + in_off_, capacity_ - in_off_};
result[1] = const_buffer{begin_, in_size_ - (capacity_ - in_off_)};
}
return result;
return {
net::const_buffer{
begin_ + in_off_, in_size_},
net::const_buffer{
begin_, 0}};
return {
net::const_buffer{
begin_ + in_off_, capacity_ - in_off_},
net::const_buffer{
begin_, in_size_ - (capacity_ - in_off_)}};
}
auto
@ -54,19 +52,17 @@ static_buffer_base::
data() noexcept ->
mutable_data_type
{
using net::mutable_buffer;
mutable_data_type result;
if(in_off_ + in_size_ <= capacity_)
{
result[0] = mutable_buffer{begin_ + in_off_, in_size_};
result[1] = mutable_buffer{begin_, 0};
}
else
{
result[0] = mutable_buffer{begin_ + in_off_, capacity_ - in_off_};
result[1] = mutable_buffer{begin_, in_size_ - (capacity_ - in_off_)};
}
return result;
return {
net::mutable_buffer{
begin_ + in_off_, in_size_},
net::mutable_buffer{
begin_, 0}};
return {
net::mutable_buffer{
begin_ + in_off_, capacity_ - in_off_},
net::mutable_buffer{
begin_, in_size_ - (capacity_ - in_off_)}};
}
auto
@ -79,19 +75,19 @@ prepare(std::size_t n) ->
BOOST_THROW_EXCEPTION(std::length_error{
"buffer overflow"});
out_size_ = n;
auto const out_off = (in_off_ + in_size_) % capacity_;
mutable_buffers_type result;
auto const out_off =
(in_off_ + in_size_) % capacity_;
if(out_off + out_size_ <= capacity_ )
{
result[0] = mutable_buffer{begin_ + out_off, out_size_};
result[1] = mutable_buffer{begin_, 0};
}
else
{
result[0] = mutable_buffer{begin_ + out_off, capacity_ - out_off};
result[1] = mutable_buffer{begin_, out_size_ - (capacity_ - out_off)};
}
return result;
return {
net::mutable_buffer{
begin_ + out_off, out_size_},
net::mutable_buffer{
begin_, 0}};
return {
net::mutable_buffer{
begin_ + out_off, capacity_ - out_off},
net::mutable_buffer{
begin_, out_size_ - (capacity_ - out_off)}};
}
void

View File

@ -46,7 +46,8 @@ public:
BOOST_STATIC_ASSERT(std::is_convertible<
multi_buffer::mutable_data_type,
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<
multi_buffer::const_buffers_type>::value);
BOOST_STATIC_ASSERT(std::is_trivially_copyable<