title: Add or modify a nullptr Vector from a partially filled flatbuffer?
body: <p>This builds off of the monster schema example. If I partially fill a flatbuffer such as in the official <a href="https://github.com/google/flatbuffers/blob/615616cb5549a34bdf288c04bc1b94bd7a65c396/tests/test.cpp#L169-L177" rel="nofollow noreferrer">test.cpp</a>.</p>
  <p>Relevant lines also copied below</p>
  <pre class="lang-cpp prettyprint-override"><code>// Create a mostly empty FlatBuffer.
  flatbuffers::FlatBufferBuilder nested_builder;
  auto nmloc = CreateMonster(nested_builder, nullptr, 0, 0,
                             nested_builder.CreateString(&quot;NestedMonster&quot;));
  FinishMonsterBuffer(nested_builder, nmloc);
  </code></pre>
  <p>How can I modify the inventory part of the schema from nested_builder after already calling <code>FinishMonsterBuffer(nested_builder, nmloc);</code>?</p>
  <p>Things I've tried (related to <a href="https://github.com/google/flatbuffers/blob/615616cb5549a34bdf288c04bc1b94bd7a65c396/tests/test.cpp#L1064-L1085" rel="nofollow noreferrer">test.cpp</a>):</p>
  <pre class="lang-cpp prettyprint-override"><code>std::string bfbsfile;
  bool found = flatbuffers::LoadFile( &quot;./monster_schema.bfbs&quot;, true, &amp;bfbsfile );
  const reflection::Schema&amp; schema = *reflection::GetSchema( bfbsfile.c_str() );
  auto root_table = schema.root_table();
  
  auto fields = root_table-&gt;fields();
  
  // The above works fine I've tested the fields and verified the schema.
  // I'm unsure of the code below.
  
  // First we put the FlatBuffer inside an std::vector.
  std::vector&lt;uint8_t&gt; resizingbuf(
      nested_builder.GetBufferPointer(), 
      nested_builder.GetBufferPointer() + nested_builder.GetSize());
  // Get the root.
  // This time we wrap the result from GetAnyRoot in a smartpointer that
  // will keep rroot valid as resizingbuf resizes.
  auto rroot = flatbuffers::piv(flatbuffers::GetAnyRoot(resizingbuf.data()),
                                resizingbuf);
  // Now lets try to extend a vector by 100 elements (0 -&gt; 110).
  auto &amp;inventory_field = *fields-&gt;LookupByKey(&quot;inventory&quot;);
  // I don't think this works either if it doesn't already exist.
  auto rinventory = flatbuffers::piv(
       flatbuffers::GetFieldV&lt;uint8_t&gt;(**rroot, inventory_field), resizingbuf);
  
  // This line silently fails probably because *rinventory is probably a nullptr  
  // but I don't know how to set it after having already 
  // called FinishMonsterBuffer(nested_builder, nmloc);.
  flatbuffers::ResizeVector&lt;uint8_t&gt;(schema, 110, 50, *rinventory,
                                     &amp;resizingbuf);
  // Try to print it but prints nothing.
  // printf(&quot;%hhu&quot;, rinventory-&gt;Get(10));
  </code></pre>
  <p>Apologies in advance for the title I'm not quite sure how to phrase the exact problem or question.
  Let me know if more context is needed or part of the question doesn't make sense.</p>