title: Copy a std::vector to a repeated field from protobuf with memcpy
body: <p>At first I have this simple protobuf file</p>
  <pre><code>message messagetest
  {
      ...
      repeated float samples = 6;
      ....
  }
  </code></pre>
  <p>Which creates a headerfile with this methods</p>
   <pre class="lang-cpp prettyprint-override"><code>    //repeated float samples = 6;
        inline int samples_size() const;
        inline void clear_samples();
        static const int kSamplesFieldNumber = 6;
        inline float samples(int index) const;
        inline void set_samples(int index, float value);
        inline void add_samples(float value);
        inline const ::google::protobuf::RepeatedField&lt; float &gt;&amp;  samples() const;
        inline ::google::protobuf::RepeatedField&lt; float &gt;* mutable_samples();
  </code></pre>
  <p>What I'm basically doing is to copy all data one by one in a for loop.</p>
  <pre><code>int main(int argc, char** argv)
  {    
      messagetest fMessage;
      
      vector&lt;float&gt; fData (1000, 0);
  
      // Create 1000 random values
      for (int i = 0; i &lt; fData.size(); i++)
      {
          fData[i] = rand() % 1001;
      }
      
      for (int j = 0; j &lt; fData.size(); j++)
      {
          fMessage.add_samples(fData[j]);    
      }
  
      return 0;
  }
  </code></pre>
  <p>But I want to use a method like memcpy to accelerate the copy process. It is just an idea that comes to my mind. If it's completely wrong correct me.
  The last declaration in the headerfile is:</p>
  <pre><code>inline ::google::protobuf::RepeatedField&lt; float &gt;* mutable_samples();
  </code></pre>
  <p>I have no idea what this method does (lack of skill). But it kind of looks like a vector. Maybe that's the solution for my problem. If so, I have no idea how to implement it.</p>