title: If I use the memcpy function to copy an array, what possible consequences: bottlenecks and perfomance changes?
body: <p>I am trying to implement my container Vector for an educational purpose.<br>
  While implementing it`s <strong>method reserve</strong> I faced the question:<br>
  <strong>that is the best way of relocation of array of elements from one place in memory (initial capacity)
  to the memory allocated for a new capacity?</strong><br>
  I consider 2 possibilities: using loop or using c function <strong>memcpy</strong>.<br>
  Here is my implementation:</p>
  
  <pre><code>template &lt;typename T&gt;
  void MyVector&lt;T&gt;::reserve(int elements) 
  {
      if (m_size &gt;= elements) // when no need to reserve memory as at least demanded amount of memory has been already allocated
          return;
      m_capacity = elements;
      tmp = m_array;
      // allocate needed amout of memory:
      m_array = new T[elements];
      // copy elements ???? can I use memcpy????
      for (int i = 0; i &lt; m_size; ++i)
      {
          m_array[i] = tmp[i];
      }
      delete tmp;
  }
  
  template &lt;typename T&gt;
  void MyVector&lt;T&gt;::reserve1(int elements) 
  {
      if (m_size &gt;= elements) // when no need to reserve memory as at least demanded amount of memory has been already allocated
          return;
      m_capacity = elements;
      tmp = m_array;
      // allocate needed amout of memory:
      m_array = new T[elements];
      // copy elements ???? can I use memcpy????
      memcpy(m_array, tmp, m_size);
      delete [] tmp;
  }
  </code></pre>
  
  <p><strong>Questions:</strong> 
  - what bottlenecks should I take into account?<br>
  - what difference in performance?<br>
  - are there more efficient methods?<br>
  - can you advice my a source of info where implementation of STL containers described in depth (my aim is to made my own implementation and when compare with professional implementation in order to check my knowledge and to find out what areas need improvement)</p>