title: Using std::vector as view on to raw memory
body: <p>I'm using a external library which at some point gives me a raw pointer to an array of integers and a size.</p>
  
  <p>Now I'd like to use <code>std::vector</code> to access and modify these values in place, rather than accessing them with raw pointers.</p>
  
  <p>Here is an articifial example that explains the point:</p>
  
  <pre><code>size_t size = 0;
  int * data = get_data_from_library(size);   // raw data from library {5,3,2,1,4}, size gets filled in
  
  std::vector&lt;int&gt; v = ????;                  // pseudo vector to be used to access the raw data
  
  std::sort(v.begin(), v.end());              // sort raw data in place
  
  for (int i = 0; i &lt; 5; i++)
  {
    std::cout &lt;&lt; data[i] &lt;&lt; "\n";             // display sorted raw data 
  }
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>1
  2
  3
  4
  5
  </code></pre>
  
  <p>The reason is that I need to apply algorithms from <code>&lt;algorithm&gt;</code> (sorting, swaping elements etc.) on that data.</p>
  
  <p>On the other hand changing the size of that vector would never be changed, so <code>push_back</code>, <code>erase</code>, <code>insert</code> are not required to work on that vector.</p>
  
  <p>I could construct a vector based on the data from the library, use modify that vector and copying the data back to to library, but that would be two complete copies that I'd like to avoid as the data set could be really big.</p>