Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: mojo/public/cpp/bindings/array.h

Issue 2038273002: Remove base/move.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: is_constructible Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/move.h" 16 #include "base/macros.h"
17 #include "mojo/public/cpp/bindings/lib/array_internal.h" 17 #include "mojo/public/cpp/bindings/lib/array_internal.h"
18 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" 18 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
19 #include "mojo/public/cpp/bindings/lib/template_util.h" 19 #include "mojo/public/cpp/bindings/lib/template_util.h"
20 #include "mojo/public/cpp/bindings/type_converter.h" 20 #include "mojo/public/cpp/bindings/type_converter.h"
21 21
22 namespace mojo { 22 namespace mojo {
23 23
24 // Represents a moveable array with contents of type |T|. The array can be null, 24 // Represents a moveable array with contents of type |T|. The array can be null,
25 // meaning that no value has been assigned to it. Null is distinct from empty. 25 // meaning that no value has been assigned to it. Null is distinct from empty.
26 template <typename T> 26 template <typename T>
27 class Array { 27 class Array {
28 MOVE_ONLY_TYPE_FOR_CPP_03(Array);
29
30 public: 28 public:
31 using ConstRefType = typename std::vector<T>::const_reference; 29 using ConstRefType = typename std::vector<T>::const_reference;
32 using RefType = typename std::vector<T>::reference; 30 using RefType = typename std::vector<T>::reference;
33 31
34 using Element = T; 32 using Element = T;
35 using Data_ = internal::Array_Data< 33 using Data_ = internal::Array_Data<
36 typename internal::GetDataTypeAsArrayElement<T>::Data>; 34 typename internal::GetDataTypeAsArrayElement<T>::Data>;
37 35
38 using iterator = typename std::vector<T>::iterator; 36 using iterator = typename std::vector<T>::iterator;
39 using const_iterator = typename std::vector<T>::const_iterator; 37 using const_iterator = typename std::vector<T>::const_iterator;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 template <typename U> 206 template <typename U>
209 bool operator!=(const Array<U>& other) const = delete; 207 bool operator!=(const Array<U>& other) const = delete;
210 208
211 void Take(Array* other) { 209 void Take(Array* other) {
212 operator=(nullptr); 210 operator=(nullptr);
213 Swap(other); 211 Swap(other);
214 } 212 }
215 213
216 std::vector<T> vec_; 214 std::vector<T> vec_;
217 bool is_null_; 215 bool is_null_;
216
217 DISALLOW_COPY_AND_ASSIGN(Array);
218 }; 218 };
219 219
220 // A |TypeConverter| that will create an |Array<T>| containing a copy of the 220 // A |TypeConverter| that will create an |Array<T>| containing a copy of the
221 // contents of an |std::vector<E>|, using |TypeConverter<T, E>| to copy each 221 // contents of an |std::vector<E>|, using |TypeConverter<T, E>| to copy each
222 // element. The returned array will always be non-null. 222 // element. The returned array will always be non-null.
223 template <typename T, typename E> 223 template <typename T, typename E>
224 struct TypeConverter<Array<T>, std::vector<E>> { 224 struct TypeConverter<Array<T>, std::vector<E>> {
225 static Array<T> Convert(const std::vector<E>& input) { 225 static Array<T> Convert(const std::vector<E>& input) {
226 Array<T> result(input.size()); 226 Array<T> result(input.size());
227 for (size_t i = 0; i < input.size(); ++i) 227 for (size_t i = 0; i < input.size(); ++i)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 if (a.is_null()) 280 if (a.is_null())
281 return !b.is_null(); 281 return !b.is_null();
282 if (b.is_null()) 282 if (b.is_null())
283 return false; 283 return false;
284 return a.storage() < b.storage(); 284 return a.storage() < b.storage();
285 } 285 }
286 286
287 } // namespace mojo 287 } // namespace mojo
288 288
289 #endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_ 289 #endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_H_
OLDNEW
« no previous file with comments | « mojo/edk/embedder/scoped_platform_handle.h ('k') | mojo/public/cpp/bindings/associated_interface_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698