Fix some issues in allocator_delete
authorJordan DeLong <jdelong@fb.com>
Mon, 3 Jun 2013 23:14:50 +0000 (16:14 -0700)
committerSara Golemon <sgolemon@fb.com>
Tue, 4 Jun 2013 20:57:20 +0000 (13:57 -0700)
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

index 3be3d78f8c86bca3844056ccbbf08282e786691f..5a1059bd5fa70fa09449bb4f22556d26e971fbc5 100644 (file)
@@ -208,6 +208,8 @@ class allocator_delete
   typedef typename std::remove_reference<Allocator>::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<allocator_delete*>(this);
+  }
 
-  void operator()(typename allocator_type::pointer p) const {
+  void operator()(pointer p) const {
     if (!p) return;
     const_cast<allocator_delete*>(this)->destroy(p);
     const_cast<allocator_delete*>(this)->deallocate(p, 1);