mirror of
https://github.com/boostorg/beast.git
synced 2025-08-02 14:24:31 +02:00
@@ -6,6 +6,7 @@ Version 51
|
|||||||
* Use BOOST_FALLTHROUGH
|
* Use BOOST_FALLTHROUGH
|
||||||
* Use BOOST_STRINGIZE
|
* Use BOOST_STRINGIZE
|
||||||
* DynamicBuffer benchmarks
|
* DynamicBuffer benchmarks
|
||||||
|
* Add construct, destroy to handler_alloc
|
||||||
|
|
||||||
API Changes:
|
API Changes:
|
||||||
|
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <beast/config.hpp>
|
#include <beast/config.hpp>
|
||||||
#include <boost/asio/handler_alloc_hook.hpp>
|
#include <boost/asio/handler_alloc_hook.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -96,7 +97,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
value_type*
|
value_type*
|
||||||
allocate(std::ptrdiff_t n)
|
allocate(size_type n)
|
||||||
{
|
{
|
||||||
auto const size = n * sizeof(T);
|
auto const size = n * sizeof(T);
|
||||||
using boost::asio::asio_handler_allocate;
|
using boost::asio::asio_handler_allocate;
|
||||||
@@ -105,21 +106,28 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
deallocate(value_type* p, std::ptrdiff_t n)
|
deallocate(value_type* p, size_type n)
|
||||||
{
|
{
|
||||||
auto const size = n * sizeof(T);
|
auto const size = n * sizeof(T);
|
||||||
using boost::asio::asio_handler_deallocate;
|
using boost::asio::asio_handler_deallocate;
|
||||||
asio_handler_deallocate(p, size, std::addressof(h_));
|
asio_handler_deallocate(p, size, std::addressof(h_));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
//#if BOOST_WORKAROUND(BOOST_GCC, < 60000) // Works, but too coarse
|
||||||
// Work-around for MSVC not using allocator_traits
|
|
||||||
// in the implementation of shared_ptr
|
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000
|
||||||
//
|
template<class U, class... Args>
|
||||||
void
|
void
|
||||||
destroy(T* t)
|
construct(U* ptr, Args&&... args)
|
||||||
{
|
{
|
||||||
t->~T();
|
::new((void*)ptr) U(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class U>
|
||||||
|
void
|
||||||
|
destroy(U* ptr)
|
||||||
|
{
|
||||||
|
ptr->~U();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
#include <beast/core/handler_alloc.hpp>
|
#include <beast/core/handler_alloc.hpp>
|
||||||
|
|
||||||
#include <beast/unit_test/suite.hpp>
|
#include <beast/unit_test/suite.hpp>
|
||||||
|
#include <list>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace beast {
|
namespace beast {
|
||||||
@@ -24,9 +25,23 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// https://github.com/vinniefalco/Beast/issues/432
|
||||||
|
void
|
||||||
|
testRegression432()
|
||||||
|
{
|
||||||
|
handler h;
|
||||||
|
handler_alloc<int, handler> a{h};
|
||||||
|
std::list<int, handler_alloc<int, handler>> v{a};
|
||||||
|
v.push_back(1);
|
||||||
|
v.push_back(2);
|
||||||
|
v.push_back(3);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
run() override
|
run() override
|
||||||
{
|
{
|
||||||
|
testRegression432();
|
||||||
|
|
||||||
handler h;
|
handler h;
|
||||||
handler h2;
|
handler h2;
|
||||||
handler_alloc<char, handler> a1{h};
|
handler_alloc<char, handler> a1{h};
|
||||||
|
Reference in New Issue
Block a user