diff options
Diffstat (limited to 'boost/beast/core/impl/async_base.hpp')
-rw-r--r-- | boost/beast/core/impl/async_base.hpp | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/boost/beast/core/impl/async_base.hpp b/boost/beast/core/impl/async_base.hpp index ec17b1cc1e..8dc8cb29a9 100644 --- a/boost/beast/core/impl/async_base.hpp +++ b/boost/beast/core/impl/async_base.hpp @@ -42,8 +42,9 @@ struct allocate_stable_state final allocate_stable_state>; A a(this->get()); - detail::allocator_traits<A>::destroy(a, this); - detail::allocator_traits<A>::deallocate(a, this, 1); + auto* p = this; + p->~allocate_stable_state(); + a.deallocate(p, 1); } }; @@ -118,33 +119,30 @@ allocate_stable( { using allocator_type = typename stable_async_base< Handler, Executor1, Allocator>::allocator_type; - + using state = detail::allocate_stable_state< + State, allocator_type>; using A = typename detail::allocator_traits< - allocator_type>::template rebind_alloc< - detail::allocate_stable_state< - State, allocator_type>>; + allocator_type>::template rebind_alloc<state>; struct deleter { allocator_type alloc; - detail::allocate_stable_state< - State, allocator_type>* ptr; + state* ptr; ~deleter() { if(ptr) { A a(alloc); - detail::allocator_traits<A>::deallocate(a, ptr, 1); + a.deallocate(ptr, 1); } } }; A a(base.get_allocator()); - deleter d{base.get_allocator(), nullptr}; - d.ptr = detail::allocator_traits<A>::allocate(a, 1); - detail::allocator_traits<A>::construct(a, d.ptr, - d.alloc, std::forward<Args>(args)...); + deleter d{base.get_allocator(), a.allocate(1)}; + ::new(static_cast<void*>(d.ptr)) + state(d.alloc, std::forward<Args>(args)...); d.ptr->next_ = base.list_; base.list_ = d.ptr; return boost::exchange(d.ptr, nullptr)->value; |