forked from boostorg/beast
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:
1 parent
5e98c78951
commit
82e87ea188
4 files changed
+21
-7
No files matched your search
@@ -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