Chromium Code Reviews| Index: src/vector.h |
| diff --git a/src/vector.h b/src/vector.h |
| index e4637c91c9804fe5f191976e0ed1a0f9e7a4979c..d120dfc4ac70c36ff9cbc7340546b356f529babd 100644 |
| --- a/src/vector.h |
| +++ b/src/vector.h |
| @@ -24,6 +24,9 @@ class Vector { |
| DCHECK(length == 0 || (length > 0 && data != NULL)); |
| } |
| + template <int N> |
| + explicit Vector(T (&arr)[N]) : start_(arr), length_(N) {} |
| + |
| static Vector<T> New(int length) { |
| return Vector<T>(NewArray<T>(length), length); |
| } |
| @@ -201,6 +204,10 @@ inline Vector<char> MutableCStrVector(char* data, int max) { |
| return Vector<char>(data, (length < max) ? length : max); |
| } |
| +template <typename T, int N> |
|
titzer
2016/04/22 11:46:30
Since this is only ever used for C strings (now),
Clemens Hammacher
2016/04/22 13:47:54
CStrVector is already there, but it takes a const
titzer
2016/04/22 13:51:45
Yeah, I'd rather just make a small addition now an
|
| +inline Vector<T> ArrayVector(T (&arr)[N]) { |
| + return Vector<T>(arr); |
| +} |
| } // namespace internal |
| } // namespace v8 |