Fixed support for allocators with explicit copy constructors (#234)

* added tests for explicit allocators

* made explicit_alloc_ctor_tests work
by adhering to the principle that classes templated with Allocator should accept exactly Allocator objects

* removed TMP machinery older compilers choke about

* initialized variables

* updated release notes

* fixed PR number
This commit is contained in:
joaquintides authored and GitHub committed 2024-02-17 18:58:48 +01:00
1 parent 7692065552
commit 15cfef6967
11 files changed
+215 -32

No files matched your search

@@ -1,6 +1,6 @@
/* Fast open-addressing concurrent hash table.
*
* Copyright 2023 Joaquin M Lopez Munoz.
* Copyright 2023-2024 Joaquin M Lopez Munoz.
* Copyright 2024 Braden Ganetsky.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -259,6 +259,7 @@ struct concurrent_table_arrays:table_arrays<Value,Group,SizePolicy,Allocator>
typename boost::allocator_pointer<group_access_allocator_type>::type;
using super=table_arrays<Value,Group,SizePolicy,Allocator>;
using allocator_type=typename super::allocator_type;
concurrent_table_arrays(const super& arrays,group_access_pointer pga):
super{arrays},group_accesses_{pga}{}
@@ -267,12 +268,11 @@ struct concurrent_table_arrays:table_arrays<Value,Group,SizePolicy,Allocator>
return boost::to_address(group_accesses_);
}
static concurrent_table_arrays new_(
group_access_allocator_type al,std::size_t n)
static concurrent_table_arrays new_(allocator_type al,std::size_t n)
{
super x{super::new_(al,n)};
BOOST_TRY{
return new_group_access(al,x);
return new_group_access(group_access_allocator_type(al),x);
}
BOOST_CATCH(...){
super::delete_(al,x);
@@ -322,10 +322,9 @@ struct concurrent_table_arrays:table_arrays<Value,Group,SizePolicy,Allocator>
return arrays;
}
static void delete_(
group_access_allocator_type al,concurrent_table_arrays& arrays)noexcept
static void delete_(allocator_type al,concurrent_table_arrays& arrays)noexcept
{
delete_group_access(al,arrays);
delete_group_access(group_access_allocator_type(al),arrays);
super::delete_(al,arrays);
}
+9 -4
View File
@@ -1,6 +1,6 @@
/* Common base for Boost.Unordered open-addressing tables.
*
* Copyright 2022-2023 Joaquin M Lopez Munoz.
* Copyright 2022-2024 Joaquin M Lopez Munoz.
* Copyright 2023 Christian Mazakas.
* Copyright 2024 Braden Ganetsky.
* Distributed under the Boost Software License, Version 1.0.
@@ -977,7 +977,12 @@ struct arrays_holder
arrays_holder(arrays_holder const&);
arrays_holder& operator=(arrays_holder const&)=delete;
~arrays_holder(){if(!released_)arrays_.delete_(al_,arrays_);}
~arrays_holder()
{
if(!released_){
arrays_.delete_(typename Arrays::allocator_type(al_),arrays_);
}
}
const Arrays& release()
{
@@ -1974,7 +1979,7 @@ private:
arrays_type new_arrays(std::size_t n)const
{
return arrays_type::new_(al(),n);
return arrays_type::new_(typename arrays_type::allocator_type(al()),n);
}
arrays_type new_arrays_for_growth()const
@@ -1995,7 +2000,7 @@ private:
void delete_arrays(arrays_type& arrays_)noexcept
{
arrays_type::delete_(al(),arrays_);
arrays_type::delete_(typename arrays_type::allocator_type(al()),arrays_);
}
arrays_holder_type make_arrays(std::size_t n)const