Bug 1049957 - Increase MakeUnique max params to 8. - r=waldo
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 15 Aug 2014 17:38:06 -0700
changeset 199928 965f780a7aa4d1f53bbd8d0b8e3d0dfbd730042c
parent 199927 d368bd458f99b9fd6cfef954acc99a5afdf84a13
child 199929 0c2662b805d2230716216777e6730527e8cf1ec0
push id9784
push userryanvm@gmail.com
push dateSat, 16 Aug 2014 21:45:40 +0000
treeherderb2g-inbound@94ba78a42305 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswaldo
bugs1049957
milestone34.0a1
Bug 1049957 - Increase MakeUnique max params to 8. - r=waldo
mfbt/UniquePtr.h
--- a/mfbt/UniquePtr.h
+++ b/mfbt/UniquePtr.h
@@ -657,17 +657,17 @@ struct UniqueSelector<T[N]>
  *
  * (And third, although not relevant to Mozilla: MakeUnique is exception-safe.
  * An exception thrown after |new T| succeeds will leak that memory, unless the
  * pointer is assigned to an object that will manage its ownership.  UniquePtr
  * ably serves this function.)
  */
 
 // We don't have variadic template support everywhere, so just hard-code arities
-// 0-5 for now.  If you need more arguments, feel free to add the extra
+// 0-8 for now.  If you need more arguments, feel free to add the extra
 // overloads (and deletions for the T = E[N] case).
 //
 // Beware!  Due to lack of true nullptr support in gcc 4.4 and 4.5, passing
 // literal nullptr to MakeUnique will not work on some platforms.  See Move.h
 // for more details.
 
 template<typename T>
 typename detail::UniqueSelector<T>::SingleObject
@@ -711,16 +711,49 @@ template<typename T, typename A1, typena
 typename detail::UniqueSelector<T>::SingleObject
 MakeUnique(A1&& aA1, A2&& aA2, A3&& aA3, A4&& aA4, A5&& aA5)
 {
   return UniquePtr<T>(new T(Forward<A1>(aA1), Forward<A2>(aA2),
                             Forward<A3>(aA3), Forward<A4>(aA4),
                             Forward<A5>(aA5)));
 }
 
+template<typename T, typename A1, typename A2, typename A3, typename A4,
+         typename A5, typename A6>
+typename detail::UniqueSelector<T>::SingleObject
+MakeUnique(A1&& a1, A2&& a2, A3&& a3, A4&& a4, A5&& a5, A6&& a6)
+{
+  return UniquePtr<T>(new T(Forward<A1>(a1), Forward<A2>(a2),
+                            Forward<A3>(a3), Forward<A4>(a4),
+                            Forward<A5>(a5), Forward<A6>(a6)));
+}
+
+template<typename T, typename A1, typename A2, typename A3, typename A4,
+         typename A5, typename A6, typename A7>
+typename detail::UniqueSelector<T>::SingleObject
+MakeUnique(A1&& a1, A2&& a2, A3&& a3, A4&& a4, A5&& a5, A6&& a6, A7&& a7)
+{
+  return UniquePtr<T>(new T(Forward<A1>(a1), Forward<A2>(a2),
+                            Forward<A3>(a3), Forward<A4>(a4),
+                            Forward<A5>(a5), Forward<A6>(a6),
+                            Forward<A7>(a7)));
+}
+
+template<typename T, typename A1, typename A2, typename A3, typename A4,
+         typename A5, typename A6, typename A7, typename A8>
+typename detail::UniqueSelector<T>::SingleObject
+MakeUnique(A1&& a1, A2&& a2, A3&& a3, A4&& a4, A5&& a5, A6&& a6, A7&& a7,
+           A8&& a8)
+{
+  return UniquePtr<T>(new T(Forward<A1>(a1), Forward<A2>(a2),
+                            Forward<A3>(a3), Forward<A4>(a4),
+                            Forward<A5>(a5), Forward<A6>(a6),
+                            Forward<A7>(a7), Forward<A8>(a8)));
+}
+
 template<typename T>
 typename detail::UniqueSelector<T>::UnknownBound
 MakeUnique(decltype(sizeof(int)) aN)
 {
   typedef typename RemoveExtent<T>::Type ArrayType;
   return UniquePtr<T>(new ArrayType[aN]());
 }
 
@@ -744,11 +777,29 @@ template<typename T, typename A1, typena
 typename detail::UniqueSelector<T>::KnownBound
 MakeUnique(A1&& aA1, A2&& aA2, A3&& aA3, A4&& aA4) MOZ_DELETE;
 
 template<typename T, typename A1, typename A2, typename A3, typename A4,
          typename A5>
 typename detail::UniqueSelector<T>::KnownBound
 MakeUnique(A1&& aA1, A2&& aA2, A3&& aA3, A4&& aA4, A5&& aA5) MOZ_DELETE;
 
+template<typename T, typename A1, typename A2, typename A3, typename A4,
+         typename A5, typename A6>
+typename detail::UniqueSelector<T>::KnownBound
+MakeUnique(A1&& a1, A2&& a2, A3&& a3, A4&& a4, A5&& a5,
+           A6&& a6) MOZ_DELETE;
+
+template<typename T, typename A1, typename A2, typename A3, typename A4,
+         typename A5, typename A6, typename A7>
+typename detail::UniqueSelector<T>::KnownBound
+MakeUnique(A1&& a1, A2&& a2, A3&& a3, A4&& a4, A5&& a5, A6&& a6,
+           A7&& a7) MOZ_DELETE;
+
+template<typename T, typename A1, typename A2, typename A3, typename A4,
+         typename A5, typename A6, typename A7, typename A8>
+typename detail::UniqueSelector<T>::KnownBound
+MakeUnique(A1&& a1, A2&& a2, A3&& a3, A4&& a4, A5&& a5, A6&& a6,
+           A7&& a7, A8&& a8) MOZ_DELETE;
+
 } // namespace mozilla
 
 #endif /* mozilla_UniquePtr_h */