mirror of
https://github.com/boostorg/beast.git
synced 2025-07-29 20:37:31 +02:00
Workaround for http-server-fast and libstdc++:
This fixes a problem where libstdc++ incorrectly assumes that the allocator used with basic_string is DefaultConstructible. See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437
This commit is contained in:
@ -3,6 +3,7 @@ Version 183:
|
||||
* Fix a rare case of failed UTF8 validation
|
||||
* Verify certificates in client examples
|
||||
* Use boost::empty_value
|
||||
* Workaround for http-server-fast and libstdc++
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
* ([issue 1233]) Use [@boost:/doc/html/core/empty_value.html `boost::empty_value`]
|
||||
|
||||
* Workaround for http-server-fast and libstdc++
|
||||
|
||||
|
||||
|
||||
[heading Boost 1.68]
|
||||
|
@ -7,6 +7,10 @@
|
||||
# Official repository: https://github.com/boostorg/beast
|
||||
#
|
||||
|
||||
# VFALCO _GLIBCXX_USE_CXX11_ABI is to work around
|
||||
# a bug in libg++8 where it attempts to default-construct
|
||||
# the allocator (even when it is not default constructible)
|
||||
|
||||
exe http-server-fast :
|
||||
http_server_fast.cpp
|
||||
:
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
template<class T>
|
||||
struct fields_alloc
|
||||
{
|
||||
detail::static_pool& pool_;
|
||||
detail::static_pool* pool_;
|
||||
|
||||
public:
|
||||
using value_type = T;
|
||||
@ -122,39 +122,46 @@ public:
|
||||
using other = fields_alloc<U>;
|
||||
};
|
||||
|
||||
#if defined(_GLIBCXX_USE_CXX11_ABI) && (_GLIBCXX_USE_CXX11_ABI == 0)
|
||||
// Workaround for g++
|
||||
// basic_string assumes that allocators are default-constructible
|
||||
// See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56437
|
||||
fields_alloc() = default;
|
||||
#endif
|
||||
|
||||
explicit
|
||||
fields_alloc(std::size_t size)
|
||||
: pool_(detail::static_pool::construct(size))
|
||||
: pool_(&detail::static_pool::construct(size))
|
||||
{
|
||||
}
|
||||
|
||||
fields_alloc(fields_alloc const& other)
|
||||
: pool_(other.pool_.share())
|
||||
: pool_(&other.pool_->share())
|
||||
{
|
||||
}
|
||||
|
||||
template<class U>
|
||||
fields_alloc(fields_alloc<U> const& other)
|
||||
: pool_(other.pool_.share())
|
||||
: pool_(&other.pool_->share())
|
||||
{
|
||||
}
|
||||
|
||||
~fields_alloc()
|
||||
{
|
||||
pool_.destroy();
|
||||
pool_->destroy();
|
||||
}
|
||||
|
||||
value_type*
|
||||
allocate(size_type n)
|
||||
{
|
||||
return static_cast<value_type*>(
|
||||
pool_.alloc(n * sizeof(T)));
|
||||
pool_->alloc(n * sizeof(T)));
|
||||
}
|
||||
|
||||
void
|
||||
deallocate(value_type*, size_type)
|
||||
{
|
||||
pool_.dealloc();
|
||||
pool_->dealloc();
|
||||
}
|
||||
|
||||
#if defined(BOOST_LIBSTDCXX_VERSION) && BOOST_LIBSTDCXX_VERSION < 60000
|
||||
|
Reference in New Issue
Block a user