Add support for custom pointers. (#258)

* Add support for custom pointers.

* Add comment

* lowercase `OpenMP` in `CMakeLists.txt`
This commit is contained in:
Gregory Popovitch
2024-11-02 17:48:08 -04:00
committed by GitHub
parent 2d0b499273
commit debe606647
5 changed files with 75 additions and 11 deletions
+1 -6
View File
@@ -926,12 +926,7 @@ private:
using IsDecomposable = IsDecomposable<void, PolicyTraits, Hash, Eq, Ts...>;
public:
static_assert(std::is_same<pointer, value_type*>::value,
"Allocators with custom pointer types are not supported");
static_assert(std::is_same<const_pointer, const value_type*>::value,
"Allocators with custom pointer types are not supported");
class iterator
class iterator
{
friend class raw_hash_set;
+1 -1
View File
@@ -4189,7 +4189,7 @@ void* Allocate(Alloc* alloc, size_t n) {
using A = typename phmap::allocator_traits<Alloc>::template rebind_alloc<M>;
using AT = typename phmap::allocator_traits<Alloc>::template rebind_traits<M>;
A mem_alloc(*alloc);
void* p = AT::allocate(mem_alloc, (n + sizeof(M) - 1) / sizeof(M));
void* p = &*AT::allocate(mem_alloc, (n + sizeof(M) - 1) / sizeof(M)); // `&*` to support custom pointers such as boost offset_ptr.
assert(reinterpret_cast<uintptr_t>(p) % Alignment == 0 &&
"allocator does not respect alignment");
return p;