Chromium Code Reviews| Index: base/stl_util.h |
| diff --git a/base/stl_util.h b/base/stl_util.h |
| index e937d2f3ed9157d433cc62fb71958bd9c71cd6d9..3edcfe4cea0fe33dc76a1ed4d8f4cf18d2533584 100644 |
| --- a/base/stl_util.h |
| +++ b/base/stl_util.h |
| @@ -98,17 +98,15 @@ STLCount(const Container& container, const T& val) { |
| return std::count(container.begin(), container.end(), val); |
| } |
| -// To treat a possibly-empty vector as an array, use these functions. |
| -// If you know the array will never be empty, you can use &*v.begin() |
| -// directly, but that is undefined behaviour if |v| is empty. |
| +// Deprecated: Use v.data() instead. |
|
danakj
2015/11/14 00:39:01
Can you just delete this in this CL?
davidben
2015/11/16 21:27:38
There's a lot more consumers. I only did a few for
|
| template<typename T> |
| inline T* vector_as_array(std::vector<T>* v) { |
| - return v->empty() ? NULL : &*v->begin(); |
| + return v->data(); |
| } |
| template<typename T> |
| inline const T* vector_as_array(const std::vector<T>* v) { |
| - return v->empty() ? NULL : &*v->begin(); |
| + return v->data(); |
| } |
| // Return a mutable char* pointing to a string's internal buffer, |