From a2d09ab3345f5f8c4ddb2e5db47c4b8366ed5669 Mon Sep 17 00:00:00 2001 From: Jordan DeLong Date: Mon, 3 Jun 2013 16:14:50 -0700 Subject: [PATCH] Fix some issues in allocator_delete Summary: The unique_ptr implementation was getting confused about how to determine the pointer type, so just tell it. Facebook: Broke the fxl build; test plan included recompiling it. Test Plan: Built. Reviewed By: marcelo.juchem@fb.com FB internal diff: D834371 --- folly/Memory.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/folly/Memory.h b/folly/Memory.h index 3be3d78f..5a1059bd 100644 --- a/folly/Memory.h +++ b/folly/Memory.h @@ -208,6 +208,8 @@ class allocator_delete typedef typename std::remove_reference::type allocator_type; public: + typedef typename Allocator::pointer pointer; + allocator_delete() = default; explicit allocator_delete(const allocator_type& allocator) @@ -223,9 +225,11 @@ public: : allocator_type(other.get_allocator()) {} - allocator_type& get_allocator() const { return *this; } + allocator_type& get_allocator() const { + return *const_cast(this); + } - void operator()(typename allocator_type::pointer p) const { + void operator()(pointer p) const { if (!p) return; const_cast(this)->destroy(p); const_cast(this)->deallocate(p, 1); -- 2.34.1