Copy a std::vector to a repeated field from protobuf with memcpy
Since this isn't here yet and I like one-liners:
*fMessage.mutable_samples() = {fData.begin(), fData.end()};
I found the shortest way to copy vector into repeated field as this:
google::protobuf::RepeatedField<float> data(fData.begin(), fData.end());
fMessage.mutable_samples()->Swap(&data);
It is probably also faster than yours since it avoids initial iteration and setting values to 0.