Add FromFlatbuffer() overload taking a const reference

Takign a const reference better represents the input types that we can
actually accept.

Continue to accept a const pointer to ease implementation of things that
need to interact with existing flatbuffers code.

Change-Id: I7809777fb8584f16edddf41f4cd844776f3e2eba
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/flatbuffers/static_vector.h b/aos/flatbuffers/static_vector.h
index bf40ce5..6133075 100644
--- a/aos/flatbuffers/static_vector.h
+++ b/aos/flatbuffers/static_vector.h
@@ -334,7 +334,10 @@
   // we can allocate through reserve()).
   // This is a deep copy, and will call FromFlatbuffer on any constituent
   // objects.
-  [[nodiscard]] bool FromFlatbuffer(ConstFlatbuffer *vector);
+  [[nodiscard]] bool FromFlatbuffer(ConstFlatbuffer *vector) {
+    return FromFlatbuffer(*CHECK_NOTNULL(vector));
+  }
+  [[nodiscard]] bool FromFlatbuffer(ConstFlatbuffer &vector);
   // The remaining FromFlatbuffer() overloads are for when using the flatbuffer
   // "object" API, which uses std::vector's for representing vectors.
   [[nodiscard]] bool FromFlatbuffer(const std::vector<InlineType> &vector) {
@@ -634,10 +637,9 @@
   }
   // Implementation that handles copying from a flatbuffers::Vector of an inline
   // data type.
-  [[nodiscard]] bool FromInlineFlatbuffer(ConstFlatbuffer *vector) {
-    return FromData(
-        reinterpret_cast<const InlineType *>(CHECK_NOTNULL(vector)->Data()),
-        vector->size());
+  [[nodiscard]] bool FromInlineFlatbuffer(ConstFlatbuffer &vector) {
+    return FromData(reinterpret_cast<const InlineType *>(vector.Data()),
+                    vector.size());
   }
 
   // Implementation that handles copying from a flatbuffers::Vector of a
@@ -658,8 +660,8 @@
     return true;
   }
 
-  [[nodiscard]] bool FromNotInlineFlatbuffer(const Flatbuffer *vector) {
-    return FromNotInlineIterable(*vector);
+  [[nodiscard]] bool FromNotInlineFlatbuffer(const Flatbuffer &vector) {
+    return FromNotInlineIterable(vector);
   }
 
   // In order to allow for easy partial template specialization, we use a
@@ -764,7 +766,7 @@
   static constexpr size_t kDataSize = T::kSize;
   template <typename StaticVector>
   static bool FromFlatbuffer(
-      StaticVector *to, const typename StaticVector::ConstFlatbuffer *from) {
+      StaticVector *to, const typename StaticVector::ConstFlatbuffer &from) {
     return to->FromNotInlineFlatbuffer(from);
   }
   template <typename StaticVector>
@@ -786,7 +788,7 @@
   static constexpr size_t kDataSize = sizeof(T);
   template <typename StaticVector>
   static bool FromFlatbuffer(
-      StaticVector *to, const typename StaticVector::ConstFlatbuffer *from) {
+      StaticVector *to, const typename StaticVector::ConstFlatbuffer &from) {
     return to->FromInlineFlatbuffer(from);
   }
   template <typename StaticVector>
@@ -806,7 +808,7 @@
   static constexpr size_t kDataSize = 1u;
   template <typename StaticVector>
   static bool FromFlatbuffer(
-      StaticVector *to, const typename StaticVector::ConstFlatbuffer *from) {
+      StaticVector *to, const typename StaticVector::ConstFlatbuffer &from) {
     return to->FromInlineFlatbuffer(from);
   }
   template <typename StaticVector>
@@ -829,7 +831,7 @@
   static constexpr size_t kDataSize = sizeof(T);
   template <typename StaticVector>
   static bool FromFlatbuffer(
-      StaticVector *to, const typename StaticVector::ConstFlatbuffer *from) {
+      StaticVector *to, const typename StaticVector::ConstFlatbuffer &from) {
     return to->FromInlineFlatbuffer(from);
   }
   template <typename StaticVector>
@@ -842,7 +844,7 @@
 template <typename T, size_t kStaticLength, bool kInline, size_t kForceAlign,
           bool kNullTerminate>
 bool Vector<T, kStaticLength, kInline, kForceAlign,
-            kNullTerminate>::FromFlatbuffer(ConstFlatbuffer *vector) {
+            kNullTerminate>::FromFlatbuffer(ConstFlatbuffer &vector) {
   return internal::InlineWrapper<T, kInline>::FromFlatbuffer(this, vector);
 }