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

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

Issue 2470233009: WTF/std normalization: replace WTF::Vector::first() with ::front() (Closed)
Patch Set: rebase Created 4 years 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/TraceWrapperMemberTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_WTF_ARRAY_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // contain any elements. 81 // contain any elements.
82 DCHECK(!is_null_ || vec_.isEmpty()); 82 DCHECK(!is_null_ || vec_.isEmpty());
83 return is_null_; 83 return is_null_;
84 } 84 }
85 85
86 // Indicates whether the array is empty (which is distinct from null). 86 // Indicates whether the array is empty (which is distinct from null).
87 bool empty() const { return vec_.isEmpty() && !is_null_; } 87 bool empty() const { return vec_.isEmpty() && !is_null_; }
88 88
89 // Returns a reference to the first element of the array. Calling this on a 89 // Returns a reference to the first element of the array. Calling this on a
90 // null or empty array causes undefined behavior. 90 // null or empty array causes undefined behavior.
91 const T& front() const { return vec_.first(); } 91 const T& front() const { return vec_.front(); }
92 T& front() { return vec_.first(); } 92 T& front() { return vec_.front(); }
93 93
94 // Returns the size of the array, which will be zero if the array is null. 94 // Returns the size of the array, which will be zero if the array is null.
95 size_t size() const { return vec_.size(); } 95 size_t size() const { return vec_.size(); }
96 96
97 // Returns a reference to the element at zero-based |offset|. Calling this on 97 // Returns a reference to the element at zero-based |offset|. Calling this on
98 // an array with size less than |offset|+1 causes undefined behavior. 98 // an array with size less than |offset|+1 causes undefined behavior.
99 const T& at(size_t offset) const { return vec_.at(offset); } 99 const T& at(size_t offset) const { return vec_.at(offset); }
100 const T& operator[](size_t offset) const { return at(offset); } 100 const T& operator[](size_t offset) const { return at(offset); }
101 T& at(size_t offset) { return vec_.at(offset); } 101 T& at(size_t offset) { return vec_.at(offset); }
102 T& operator[](size_t offset) { return at(offset); } 102 T& operator[](size_t offset) { return at(offset); }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 188
189 WTF::Vector<T> vec_; 189 WTF::Vector<T> vec_;
190 bool is_null_; 190 bool is_null_;
191 191
192 DISALLOW_COPY_AND_ASSIGN(WTFArray); 192 DISALLOW_COPY_AND_ASSIGN(WTFArray);
193 }; 193 };
194 194
195 } // namespace mojo 195 } // namespace mojo
196 196
197 #endif // MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_ 197 #endif // MOJO_PUBLIC_CPP_BINDINGS_WTF_ARRAY_H_
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/TraceWrapperMemberTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698