1

Is there a way to move STL vector to protobuf repeated? The following code works but I think it is copyng the values, not moving the values.

// foo.proto
message Foo {
  int64 a = 1;
  int64 b = 2;
}
message FooList {
  repeated Foo foos = 1;
}

// main.cc
FooList foo_list;
vector<Foo> v;
v.push_back({1,2});
v.push_back({3,4});
foo_list.mutable_foos() = {v.begin(), v.end()};
Hee Hwang
  • 121
  • 7

0 Answers0