Bug 1163505 - PtrVector should disallow copies to prevent premature&double deletions - r=bwc
authorGerald Squelart <gsquelart@mozilla.com>
Sun, 17 May 2015 16:19:00 +0200
changeset 244300 2d331d4ba0f5e18dcd31fa984178ff8d547cdce7
parent 244299 a9a7bb0afb7b3723fab198d2837ceccc9dca04ac
child 244301 6dd7de1d30276c2e37c57190e6d248237aff6c3b
push id59893
push usercbook@mozilla.com
push dateMon, 18 May 2015 07:08:54 +0000
treeherdermozilla-inbound@6dd7de1d3027 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbwc
bugs1163505
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1163505 - PtrVector should disallow copies to prevent premature&double deletions - r=bwc
media/webrtc/signaling/src/common/PtrVector.h
--- a/media/webrtc/signaling/src/common/PtrVector.h
+++ b/media/webrtc/signaling/src/common/PtrVector.h
@@ -1,26 +1,39 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef PtrVector_h
 #define PtrVector_h
 
+#include <mozilla/Move.h>
 #include <vector>
 
 namespace mozilla
 {
 
 // Trivial wrapper class around a vector of ptrs.
 // TODO: Remove this once our buildconfig allows us to put unique_ptr in stl
 // containers, and just use std::vector<unique_ptr<T>> instead.
 template <class T> class PtrVector
 {
 public:
+  PtrVector() = default;
+  PtrVector(const PtrVector&) = delete;
+  PtrVector(PtrVector&& aOther)
+    : values(Move(aOther.values))
+  {}
+  PtrVector& operator=(const PtrVector&) = delete;
+  PtrVector& operator=(PtrVector&& aOther)
+  {
+    Swap(values, aOther.values);
+    return *this;
+  }
+
   ~PtrVector()
   {
     for (T* value : values) { delete value; }
   }
 
   std::vector<T*> values;
 };