mirror of
https://github.com/boostorg/beast.git
synced 2025-08-03 23:04:35 +02:00
Tidy up basic_fields exception specifiers
fix #894 Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
This commit is contained in:
committed by
Vinnie Falco
parent
7ac24d77be
commit
190d20e3a8
@@ -3,6 +3,10 @@ Version 147:
|
|||||||
* Don't use boost::string_ref
|
* Don't use boost::string_ref
|
||||||
* Use iterator wrapper in detail::buffers_range
|
* Use iterator wrapper in detail::buffers_range
|
||||||
|
|
||||||
|
HTTP:
|
||||||
|
|
||||||
|
* Tidy up basic_fields exception specifiers
|
||||||
|
|
||||||
WebSocket:
|
WebSocket:
|
||||||
|
|
||||||
* control callback is copied or moved
|
* control callback is copied or moved
|
||||||
|
@@ -188,6 +188,19 @@ private:
|
|||||||
boost::intrusive::constant_time_size<true>,
|
boost::intrusive::constant_time_size<true>,
|
||||||
boost::intrusive::compare<key_compare>>::type;
|
boost::intrusive::compare<key_compare>>::type;
|
||||||
|
|
||||||
|
using align_type = typename
|
||||||
|
boost::type_with_alignment<alignof(value_type)>::type;
|
||||||
|
|
||||||
|
using rebind_type = typename
|
||||||
|
beast::detail::allocator_traits<Allocator>::
|
||||||
|
template rebind_alloc<align_type>;
|
||||||
|
|
||||||
|
using alloc_traits =
|
||||||
|
beast::detail::allocator_traits<rebind_type>;
|
||||||
|
|
||||||
|
using size_type = typename
|
||||||
|
beast::detail::allocator_traits<Allocator>::size_type;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Destructor
|
/// Destructor
|
||||||
@@ -201,14 +214,14 @@ public:
|
|||||||
@param alloc The allocator to use.
|
@param alloc The allocator to use.
|
||||||
*/
|
*/
|
||||||
explicit
|
explicit
|
||||||
basic_fields(Allocator const& alloc);
|
basic_fields(Allocator const& alloc) noexcept;
|
||||||
|
|
||||||
/** Move constructor.
|
/** Move constructor.
|
||||||
|
|
||||||
The state of the moved-from object is
|
The state of the moved-from object is
|
||||||
as if constructed using the same allocator.
|
as if constructed using the same allocator.
|
||||||
*/
|
*/
|
||||||
basic_fields(basic_fields&&);
|
basic_fields(basic_fields&&) noexcept;
|
||||||
|
|
||||||
/** Move constructor.
|
/** Move constructor.
|
||||||
|
|
||||||
@@ -245,7 +258,8 @@ public:
|
|||||||
The state of the moved-from object is
|
The state of the moved-from object is
|
||||||
as if constructed using the same allocator.
|
as if constructed using the same allocator.
|
||||||
*/
|
*/
|
||||||
basic_fields& operator=(basic_fields&&);
|
basic_fields& operator=(basic_fields&&) noexcept(
|
||||||
|
alloc_traits::propagate_on_container_move_assignment::value);
|
||||||
|
|
||||||
/// Copy assignment.
|
/// Copy assignment.
|
||||||
basic_fields& operator=(basic_fields const&);
|
basic_fields& operator=(basic_fields const&);
|
||||||
@@ -690,19 +704,6 @@ private:
|
|||||||
template<class OtherAlloc>
|
template<class OtherAlloc>
|
||||||
friend class basic_fields;
|
friend class basic_fields;
|
||||||
|
|
||||||
using align_type = typename
|
|
||||||
boost::type_with_alignment<alignof(value_type)>::type;
|
|
||||||
|
|
||||||
using rebind_type = typename
|
|
||||||
beast::detail::allocator_traits<Allocator>::
|
|
||||||
template rebind_alloc<align_type>;
|
|
||||||
|
|
||||||
using alloc_traits =
|
|
||||||
beast::detail::allocator_traits<rebind_type>;
|
|
||||||
|
|
||||||
using size_type = typename
|
|
||||||
beast::detail::allocator_traits<Allocator>::size_type;
|
|
||||||
|
|
||||||
value_type&
|
value_type&
|
||||||
new_element(field name,
|
new_element(field name,
|
||||||
string_view sname, string_view value);
|
string_view sname, string_view value);
|
||||||
|
@@ -349,14 +349,14 @@ basic_fields<Allocator>::
|
|||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
basic_fields<Allocator>::
|
basic_fields<Allocator>::
|
||||||
basic_fields(Allocator const& alloc)
|
basic_fields(Allocator const& alloc) noexcept
|
||||||
: beast::detail::empty_base_optimization<Allocator>(alloc)
|
: beast::detail::empty_base_optimization<Allocator>(alloc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
basic_fields<Allocator>::
|
basic_fields<Allocator>::
|
||||||
basic_fields(basic_fields&& other)
|
basic_fields(basic_fields&& other) noexcept
|
||||||
: beast::detail::empty_base_optimization<Allocator>(
|
: beast::detail::empty_base_optimization<Allocator>(
|
||||||
std::move(other.member()))
|
std::move(other.member()))
|
||||||
, set_(std::move(other.set_))
|
, set_(std::move(other.set_))
|
||||||
@@ -426,9 +426,12 @@ basic_fields(basic_fields<OtherAlloc> const& other,
|
|||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
auto
|
auto
|
||||||
basic_fields<Allocator>::
|
basic_fields<Allocator>::
|
||||||
operator=(basic_fields&& other) ->
|
operator=(basic_fields&& other) noexcept(
|
||||||
basic_fields&
|
alloc_traits::propagate_on_container_move_assignment::value)
|
||||||
|
-> basic_fields&
|
||||||
{
|
{
|
||||||
|
static_assert(is_nothrow_move_assignable<Allocator>::value,
|
||||||
|
"Allocator must be noexcept assignable.");
|
||||||
if(this == &other)
|
if(this == &other)
|
||||||
return *this;
|
return *this;
|
||||||
move_assign(other, std::integral_constant<bool,
|
move_assign(other, std::integral_constant<bool,
|
||||||
|
@@ -21,11 +21,64 @@ namespace boost {
|
|||||||
namespace beast {
|
namespace beast {
|
||||||
namespace http {
|
namespace http {
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT(is_fields<fields>::value);
|
|
||||||
|
|
||||||
class fields_test : public beast::unit_test::suite
|
class fields_test : public beast::unit_test::suite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
template <class T>
|
||||||
|
class test_allocator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using value_type = T;
|
||||||
|
|
||||||
|
test_allocator() noexcept(false) {}
|
||||||
|
|
||||||
|
template <typename U, typename = typename std::enable_if<!std::is_same<test_allocator, U>::value>::type>
|
||||||
|
test_allocator(test_allocator<U> const&) noexcept {}
|
||||||
|
|
||||||
|
value_type*
|
||||||
|
allocate(std::size_t n)
|
||||||
|
{
|
||||||
|
return static_cast<value_type*>(::operator new (n*sizeof(value_type)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
deallocate(value_type* p, std::size_t) noexcept
|
||||||
|
{
|
||||||
|
::operator delete(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
friend
|
||||||
|
bool
|
||||||
|
operator==(test_allocator<T> const&, test_allocator<U> const&) noexcept
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class U>
|
||||||
|
friend
|
||||||
|
bool
|
||||||
|
operator!=(test_allocator<T> const& x, test_allocator<U> const& y) noexcept
|
||||||
|
{
|
||||||
|
return !(x == y);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
using test_fields = basic_fields<test_allocator<char>>;
|
||||||
|
|
||||||
|
BOOST_STATIC_ASSERT(is_fields<fields>::value);
|
||||||
|
BOOST_STATIC_ASSERT(is_fields<test_fields>::value);
|
||||||
|
|
||||||
|
// std::allocator is noexcept movable, fields should satisfy
|
||||||
|
// these constraints as well.
|
||||||
|
BOOST_STATIC_ASSERT(std::is_nothrow_move_constructible<fields>::value);
|
||||||
|
BOOST_STATIC_ASSERT(std::is_nothrow_move_assignable<fields>::value);
|
||||||
|
|
||||||
|
// Check if basic_fields respects throw-constructibility and
|
||||||
|
// propagate_on_container_move_assignment of the allocator.
|
||||||
|
BOOST_STATIC_ASSERT(std::is_nothrow_move_constructible<test_fields>::value);
|
||||||
|
BOOST_STATIC_ASSERT(!std::is_nothrow_move_assignable<test_fields>::value);
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
using fa_t = basic_fields<Allocator>;
|
using fa_t = basic_fields<Allocator>;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user