Re: [protobuf] Shall I put protobuf message in unique_ptr to avoid copy?

2020-09-09 Thread 'Adam Cozzette' via Protocol Buffers
That sounds like a reasonable way to do it. Another thing you could do is that if you know how big the vector will be, you can call indexVector.reserve() to reserve the correct size, then add each element with indexVector.emplace_back() and initialize its fields in place. That would let you use

[protobuf] Shall I put protobuf message in unique_ptr to avoid copy?

2020-09-09 Thread river
here is my code, should I directly usage vector ? std::vector> ret; // IndexVector is a protobuf message type, sizeof ... = 72 while (result.next()) { std::unique_ptr indexVector {std::make_unique()}; int64_t poiId = result.getLLong(1); int64_t pictureId =