easier rebinding of allocators
[folly.git] / folly / Memory.h
index e4db242ba22edc24065a249e67bc5416f47944b3..0b6c0a11c333678caaf3b4de01f55e90436f21e2 100644 (file)
@@ -169,6 +169,18 @@ class StlAllocator {
   Alloc* alloc_;
 };
 
+/**
+ * Helper function to obtain rebound allocators
+ *
+ * @author: Marcelo Juchem <marcelo@fb.com>
+ */
+template <typename T, typename Allocator>
+typename Allocator::template rebind<T>::other rebind_allocator(
+  Allocator const &allocator
+) {
+  return typename Allocator::template rebind<T>::other(allocator);
+}
+
 /*
  * Helper classes/functions for creating a unique_ptr using a custom allocator
  *