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;
     }
diff --git a/test_main.cpp b/test_main.cpp
index 90c8505..89040c3 100644
--- a/test_main.cpp
+++ b/test_main.cpp
@@ -177,9 +177,14 @@
 TEST_F(LibHidlTest, VecInitTest) {
     using android::hardware::hidl_vec;
     using std::vector;
+    int32_t empty[3] = {0};
     int32_t array[] = {5, 6, 7};
     vector<int32_t> v(array, array + 3);
 
+    hidl_vec<int32_t> hv0(3);  // size
+    EXPECT_EQ(hv0.size(), 3ul);
+    EXPECT_ARRAYEQ(hv0, empty, 3);
+
     hidl_vec<int32_t> hv1 = v; // copy =
     EXPECT_ARRAYEQ(hv1, array, 3);
     EXPECT_ARRAYEQ(hv1, v, 3);