Line data Source code
1 : /* This Source Code Form is subject to the terms of the Mozilla Public
2 : * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
4 :
5 : #ifndef PtrVector_h
6 : #define PtrVector_h
7 :
8 : #include <mozilla/Move.h>
9 : #include <vector>
10 :
11 : namespace mozilla
12 : {
13 :
14 : // Trivial wrapper class around a vector of ptrs.
15 : // TODO: Remove this once our buildconfig allows us to put unique_ptr in stl
16 : // containers, and just use std::vector<unique_ptr<T>> instead.
17 : template <class T> class PtrVector
18 : {
19 : public:
20 0 : PtrVector() = default;
21 : PtrVector(const PtrVector&) = delete;
22 : PtrVector(PtrVector&& aOther)
23 : : values(Move(aOther.values))
24 : {}
25 : PtrVector& operator=(const PtrVector&) = delete;
26 : PtrVector& operator=(PtrVector&& aOther)
27 : {
28 : Swap(values, aOther.values);
29 : return *this;
30 : }
31 :
32 0 : ~PtrVector()
33 : {
34 0 : for (T* value : values) { delete value; }
35 0 : }
36 :
37 : std::vector<T*> values;
38 : };
39 :
40 : } // namespace mozilla
41 :
42 : #endif // PtrVector_h
43 :
|