OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <string.h> | 9 #include <string.h> |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 Array() : is_null_(false) {} | 42 Array() : is_null_(false) {} |
43 // Constructs a null array. | 43 // Constructs a null array. |
44 Array(std::nullptr_t null_pointer) : is_null_(true) {} | 44 Array(std::nullptr_t null_pointer) : is_null_(true) {} |
45 | 45 |
46 // Constructs a new non-null array of the specified size. The elements will | 46 // Constructs a new non-null array of the specified size. The elements will |
47 // be value-initialized (meaning that they will be initialized by their | 47 // be value-initialized (meaning that they will be initialized by their |
48 // default constructor, if any, or else zero-initialized). | 48 // default constructor, if any, or else zero-initialized). |
49 explicit Array(size_t size) : vec_(size), is_null_(false) {} | 49 explicit Array(size_t size) : vec_(size), is_null_(false) {} |
50 ~Array() {} | 50 ~Array() {} |
51 | 51 |
| 52 // Copies the contents of |other| into this array. |
| 53 Array(const std::vector<T>& other) : vec_(other), is_null_(false) {} |
| 54 |
52 // Moves the contents of |other| into this array. | 55 // Moves the contents of |other| into this array. |
53 Array(std::vector<T>&& other) : vec_(std::move(other)), is_null_(false) {} | 56 Array(std::vector<T>&& other) : vec_(std::move(other)), is_null_(false) {} |
54 Array(Array&& other) : is_null_(true) { Take(&other); } | 57 Array(Array&& other) : is_null_(true) { Take(&other); } |
55 | 58 |
56 Array& operator=(std::vector<T>&& other) { | 59 Array& operator=(std::vector<T>&& other) { |
57 vec_ = std::move(other); | 60 vec_ = std::move(other); |
58 is_null_ = false; | 61 is_null_ = false; |
59 return *this; | 62 return *this; |
60 } | 63 } |
61 Array& operator=(Array&& other) { | 64 Array& operator=(Array&& other) { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 if (a.is_null()) | 304 if (a.is_null()) |
302 return !b.is_null(); | 305 return !b.is_null(); |
303 if (b.is_null()) | 306 if (b.is_null()) |
304 return false; | 307 return false; |
305 return a.storage() < b.storage(); | 308 return a.storage() < b.storage(); |
306 } | 309 } |
307 | 310 |
308 } // namespace mojo | 311 } // namespace mojo |
309 | 312 |
310 #endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ | 313 #endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ |
OLD | NEW |