In this question, it is answered how a vector can be copied into a repeated field by using fMessage.mutable_samples() = {fData.begin(), fData.end()};
( and the other direction works too ).
But how about a partial copy? Would the below work?
std::copy(
fData.begin() + 3, fData.end() - 2,
fMessage.mutable_samples()->begin() + 3
);
In this scenario fMessage
has already allocated elements in the samples
field, and std::copy
would overwrite the items already present in fMessage
.