Add size constructor to hidl_vec.
This pattern is everywhere:
hidl_vec<...> x;
x.resize(3);
It doesn't look very pretty.
Test: libhidl_test
Change-Id: I2776e81afbe6f12e34cfb31a2f40d539554f0cbc
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index b878423..c8d8db9 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -290,6 +290,8 @@
static_assert(hidl_vec<T>::kOffsetOfBuffer == 0, "wrong offset");
}
+ hidl_vec(size_t size) : hidl_vec() { resize(size); }
+
hidl_vec(const hidl_vec<T> &other) : hidl_vec() {
*this = other;
}