make folly:make_unique support customized deleter
authorXu Ning <xning@fb.com>
Fri, 24 May 2013 23:02:12 +0000 (16:02 -0700)
committerOwen Yamauchi <oyamauchi@fb.com>
Mon, 3 Jun 2013 19:20:40 +0000 (12:20 -0700)
Summary: just follow the same template arguments as unique_ptr

Test Plan: compile

Reviewed By: marcelo.juchem@fb.com

FB internal diff: D825025

folly/Memory.h

index 0b6c0a11c333678caaf3b4de01f55e90436f21e2..6ce239f450fc3af43132ca18472228aad09356d2 100644 (file)
@@ -34,11 +34,12 @@ namespace folly {
  * we have std::make_unique().
  *
  * @author Louis Brandy (ldbrandy@fb.com)
+ * @author Xu Ning (xning@fb.com)
  */
 
-template<typename T, typename... Args>
-std::unique_ptr<T> make_unique(Args&&... args) {
-  return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
+template<typename T, typename Dp = std::default_delete<T>, typename... Args>
+std::unique_ptr<T, Dp> make_unique(Args&&... args) {
+  return std::unique_ptr<T, Dp>(new T(std::forward<Args>(args)...));
 }
 
 /**