message: [c++] Show marshaling in protocol_versions example
diff: @@ -26,6 +26,12 @@ int main()
  obj.items.push_back(3.14);
  obj.items.push_back(0);
  + // Protocols may have different versions with different features. When
  + // serializing/deserializing the same version needs to be used.
  + //
  + // Marshaling can be used to embed the protocol and version in the
  + // payload so the reading side can automatically determine which
  + // protocol and version to use.
  {
  // If we don't pass explicit protocol version to ctor, then implicit
  // default version is used.
  @@ -37,6 +43,8 @@ int main()
  bond::InputBuffer input(output.GetBuffer());
  bond::SimpleBinaryReader<bond::InputBuffer> reader(input);
  bond::Deserialize(reader, obj2);
  +
  + BOOST_ASSERT(obj == obj2);
  }
  {
  @@ -49,6 +57,22 @@ int main()
  bond::InputBuffer input(output.GetBuffer());
  bond::SimpleBinaryReader<bond::InputBuffer> reader(input, bond::v1);
  bond::Deserialize(reader, obj2);
  +
  + BOOST_ASSERT(obj == obj2);
  + }
  +
  + {
  + // Here, we Marshal to Compact Binary v2.
  + bond::OutputBuffer output;
  + bond::CompactBinaryWriter<bond::OutputBuffer> writer(output, bond::v2);
  + bond::Marshal(obj, writer);
  +
  + Struct obj2;
  + bond::InputBuffer input(output.GetBuffer());
  + // The protocol and version are determined from the payload itself.
  + bond::Unmarshal(input, obj2);
  +
  + BOOST_ASSERT(obj == obj2);
  }
  return 0;
  