title: Copying strided data in C++
body: <p>I have two arrays and I want to copy one array into the other with some stride. For example, I have</p>
  
  <pre><code>A A A A A A A A ...
  
  B B B B B B B B ...
  </code></pre>
  
  <p>and I want to copy every three elements of <code>B</code> to <code>A</code> to obtain</p>
  
  <pre><code>B A A B A A B A ...
  </code></pre>
  
  <p>From the post "<a href="https://stackoverflow.com/questions/6013779/is-there-a-standard-strided-version-of-memcpy">Is there a standard, strided version of memcpy?</a>", it seems that there is no such a possibility in C.</p>
  
  <p>However, I have experienced that, in some cases, <code>memcpy</code> is faster than a <code>for</code> loop based copy.</p>
  
  <p>My question is; <em>Is there any way to efficiently perform strided memory copy in C++ performing at least as a standard <code>for</code> loop</em>?</p>
  
  <p>Thank you very much.</p>
  
  <p><strong>EDIT - CLARIFICATION OF THE PROBLEM</strong></p>
  
  <p>To make the problem clearer, let us denote the two arrays at hand by <code>a</code> and <code>b</code>. I have a function that performs the unique following <code>for</code> loop</p>
  
  <pre><code>for (int i=0; i&lt;NumElements, i++)
      a_[i] = b_[i];
  </code></pre>
  
  <p>where both the <code>[]</code>'s are overloaded operators (I'm using an expression templates technique) so that they can be actually mean, for example</p>
  
  <pre><code> a[3*i]=b[i];
  </code></pre>