Bug 1267918 - Add do_AddRef(const RefPtr<T>& aObj). r=froydnj
authorChris Pearce <cpearce@mozilla.com>
Thu, 30 Jun 2016 10:06:10 +1200
changeset 383173 45fb3e6f39369db6abc5479bf2e129163352de88
parent 383144 0a03bb6af6043ce323142d24fb43c2d63deefbcb
child 383174 d409232655857c1d27209a02be589344f5eee903
push id21963
push userdmitchell@mozilla.com
push dateFri, 01 Jul 2016 19:54:18 +0000
reviewersfroydnj
bugs1267918
milestone50.0a1
Bug 1267918 - Add do_AddRef(const RefPtr<T>& aObj). r=froydnj This means we can return already_AddRefed<T> for any RefPtr<T>s being held as instance variables easier. MozReview-Commit-ID: HFHdkF8EUsK
mfbt/RefPtr.h
--- a/mfbt/RefPtr.h
+++ b/mfbt/RefPtr.h
@@ -597,16 +597,24 @@ operator!=(decltype(nullptr), const RefP
 template <class T>
 inline already_AddRefed<T>
 do_AddRef(T* aObj)
 {
   RefPtr<T> ref(aObj);
   return ref.forget();
 }
 
+template <class T>
+inline already_AddRefed<T>
+do_AddRef(const RefPtr<T>& aObj)
+{
+  RefPtr<T> ref(aObj);
+  return ref.forget();
+}
+
 namespace mozilla {
 
 /**
  * Helper function to be able to conveniently write things like:
  *
  *   already_AddRefed<T>
  *   f(...)
  *   {