mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 12:57:31 +02:00
committed by
Vinnie Falco
parent
c4d1bfe7af
commit
8ed039200d
@ -1,3 +1,9 @@
|
|||||||
|
Version 179:
|
||||||
|
|
||||||
|
* Use the exchange() idiom in move constructors
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Version 178:
|
Version 178:
|
||||||
|
|
||||||
* Use static_cast instead
|
* Use static_cast instead
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <boost/core/exchange.hpp>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -65,9 +66,8 @@ file_posix::
|
|||||||
inline
|
inline
|
||||||
file_posix::
|
file_posix::
|
||||||
file_posix(file_posix&& other)
|
file_posix(file_posix&& other)
|
||||||
: fd_(other.fd_)
|
: fd_(boost::exchange(other.fd_, -1))
|
||||||
{
|
{
|
||||||
other.fd_ = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_CORE_IMPL_FILE_STDIO_IPP
|
#ifndef BOOST_BEAST_CORE_IMPL_FILE_STDIO_IPP
|
||||||
#define BOOST_BEAST_CORE_IMPL_FILE_STDIO_IPP
|
#define BOOST_BEAST_CORE_IMPL_FILE_STDIO_IPP
|
||||||
|
|
||||||
|
#include <boost/core/exchange.hpp>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
@ -26,9 +27,8 @@ file_stdio::
|
|||||||
inline
|
inline
|
||||||
file_stdio::
|
file_stdio::
|
||||||
file_stdio(file_stdio&& other)
|
file_stdio(file_stdio&& other)
|
||||||
: f_(other.f_)
|
: f_(boost::exchange(other.f_, nullptr))
|
||||||
{
|
{
|
||||||
other.f_ = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_CORE_IMPL_FILE_WIN32_IPP
|
#ifndef BOOST_BEAST_CORE_IMPL_FILE_WIN32_IPP
|
||||||
#define BOOST_BEAST_CORE_IMPL_FILE_WIN32_IPP
|
#define BOOST_BEAST_CORE_IMPL_FILE_WIN32_IPP
|
||||||
|
|
||||||
|
#include <boost/core/exchange.hpp>
|
||||||
#include <boost/winapi/access_rights.hpp>
|
#include <boost/winapi/access_rights.hpp>
|
||||||
#include <boost/winapi/error_codes.hpp>
|
#include <boost/winapi/error_codes.hpp>
|
||||||
#include <boost/winapi/file_management.hpp>
|
#include <boost/winapi/file_management.hpp>
|
||||||
@ -61,9 +62,8 @@ file_win32::
|
|||||||
inline
|
inline
|
||||||
file_win32::
|
file_win32::
|
||||||
file_win32(file_win32&& other)
|
file_win32(file_win32&& other)
|
||||||
: h_(other.h_)
|
: h_(boost::exchange(other.h_, boost::winapi::INVALID_HANDLE_VALUE_))
|
||||||
{
|
{
|
||||||
other.h_ = boost::winapi::INVALID_HANDLE_VALUE_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#ifndef BOOST_BEAST_IMPL_FLAT_BUFFER_HPP
|
#ifndef BOOST_BEAST_IMPL_FLAT_BUFFER_HPP
|
||||||
#define BOOST_BEAST_IMPL_FLAT_BUFFER_HPP
|
#define BOOST_BEAST_IMPL_FLAT_BUFFER_HPP
|
||||||
|
|
||||||
|
#include <boost/core/exchange.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@ -86,18 +87,14 @@ basic_flat_buffer<Allocator>::
|
|||||||
basic_flat_buffer(basic_flat_buffer&& other)
|
basic_flat_buffer(basic_flat_buffer&& other)
|
||||||
: detail::empty_base_optimization<base_alloc_type>(
|
: detail::empty_base_optimization<base_alloc_type>(
|
||||||
std::move(other.member()))
|
std::move(other.member()))
|
||||||
, begin_(other.begin_)
|
, begin_(boost::exchange(other.begin_, nullptr))
|
||||||
, in_(other.in_)
|
, in_(boost::exchange(other.in_, nullptr))
|
||||||
, out_(other.out_)
|
, out_(boost::exchange(other.out_, nullptr))
|
||||||
, last_(out_)
|
, last_(out_)
|
||||||
, end_(other.end_)
|
, end_(boost::exchange(other.end_, nullptr))
|
||||||
, max_(other.max_)
|
, max_(other.max_)
|
||||||
{
|
{
|
||||||
other.begin_ = nullptr;
|
|
||||||
other.in_ = nullptr;
|
|
||||||
other.out_ = nullptr;
|
|
||||||
other.last_ = nullptr;
|
other.last_ = nullptr;
|
||||||
other.end_ = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#define BOOST_BEAST_IMPL_MULTI_BUFFER_IPP
|
#define BOOST_BEAST_IMPL_MULTI_BUFFER_IPP
|
||||||
|
|
||||||
#include <boost/beast/core/detail/type_traits.hpp>
|
#include <boost/beast/core/detail/type_traits.hpp>
|
||||||
|
#include <boost/core/exchange.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -462,20 +463,16 @@ basic_multi_buffer(basic_multi_buffer&& other)
|
|||||||
: detail::empty_base_optimization<
|
: detail::empty_base_optimization<
|
||||||
base_alloc_type>(std::move(other.member()))
|
base_alloc_type>(std::move(other.member()))
|
||||||
, max_(other.max_)
|
, max_(other.max_)
|
||||||
, in_size_(other.in_size_)
|
, in_size_(boost::exchange(other.in_size_, 0))
|
||||||
, in_pos_(other.in_pos_)
|
, in_pos_(boost::exchange(other.in_pos_, 0))
|
||||||
, out_pos_(other.out_pos_)
|
, out_pos_(boost::exchange(other.out_pos_, 0))
|
||||||
, out_end_(other.out_end_)
|
, out_end_(boost::exchange(other.out_end_, 0))
|
||||||
{
|
{
|
||||||
auto const at_end =
|
auto const at_end =
|
||||||
other.out_ == other.list_.end();
|
other.out_ == other.list_.end();
|
||||||
list_ = std::move(other.list_);
|
list_ = std::move(other.list_);
|
||||||
out_ = at_end ? list_.end() : other.out_;
|
out_ = at_end ? list_.end() : other.out_;
|
||||||
other.in_size_ = 0;
|
|
||||||
other.out_ = other.list_.end();
|
other.out_ = other.list_.end();
|
||||||
other.in_pos_ = 0;
|
|
||||||
other.out_pos_ = 0;
|
|
||||||
other.out_end_ = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include <boost/beast/http/rfc7230.hpp>
|
#include <boost/beast/http/rfc7230.hpp>
|
||||||
#include <boost/beast/http/status.hpp>
|
#include <boost/beast/http/status.hpp>
|
||||||
#include <boost/beast/http/chunk_encode.hpp>
|
#include <boost/beast/http/chunk_encode.hpp>
|
||||||
|
#include <boost/core/exchange.hpp>
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -363,11 +364,9 @@ basic_fields(basic_fields&& other) noexcept
|
|||||||
std::move(other.member()))
|
std::move(other.member()))
|
||||||
, set_(std::move(other.set_))
|
, set_(std::move(other.set_))
|
||||||
, list_(std::move(other.list_))
|
, list_(std::move(other.list_))
|
||||||
, method_(other.method_)
|
, method_(boost::exchange(other.method_, {}))
|
||||||
, target_or_reason_(other.target_or_reason_)
|
, target_or_reason_(boost::exchange(other.target_or_reason_, {}))
|
||||||
{
|
{
|
||||||
other.method_ = {};
|
|
||||||
other.target_or_reason_ = {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <boost/beast/core/detail/integer_sequence.hpp>
|
#include <boost/beast/core/detail/integer_sequence.hpp>
|
||||||
#include <boost/align/aligned_alloc.hpp>
|
#include <boost/align/aligned_alloc.hpp>
|
||||||
#include <boost/asio/buffer.hpp>
|
#include <boost/asio/buffer.hpp>
|
||||||
|
#include <boost/core/exchange.hpp>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -50,9 +51,8 @@ public:
|
|||||||
soft_mutex& operator=(soft_mutex const&) = delete;
|
soft_mutex& operator=(soft_mutex const&) = delete;
|
||||||
|
|
||||||
soft_mutex(soft_mutex&& other) noexcept
|
soft_mutex(soft_mutex&& other) noexcept
|
||||||
: id_(other.id_)
|
: id_(boost::exchange(other.id_, 0))
|
||||||
{
|
{
|
||||||
other.id_ = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
soft_mutex& operator=(soft_mutex&& other) noexcept
|
soft_mutex& operator=(soft_mutex&& other) noexcept
|
||||||
@ -156,12 +156,7 @@ struct stream_prng
|
|||||||
}
|
}
|
||||||
|
|
||||||
prng_ref(prng_ref&& other)
|
prng_ref(prng_ref&& other)
|
||||||
: p_([&other]
|
: p_(boost::exchange(other.p_, nullptr))
|
||||||
{
|
|
||||||
auto p = other.p_;
|
|
||||||
other.p_ = nullptr;
|
|
||||||
return p;
|
|
||||||
}())
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user