title: trim array to elements between i and j
body: <p>A classic, I'm looking for optimisation here : I have an array of things, and after some processing I know I'm only interested in elements i to j. How to trim my array in the fatset, lightest way, with complete deletions/freeing of memory of elements before i and after j ?</p>
  
  <p>I'm doing mebedded C++, so I may not be able to compile all sorts of library let's say. But std or vector things welcome in a first phase !</p>
  
  <p>I've tried, for array A to be trimmed between i and j, with variable numElms telling me the number of elements in A :</p>
  
  <pre><code>A = &amp;A[i];
  numElms = i-j+1;
  </code></pre>
  
  <p>As it is this yields an incompatibility error. Can that be fixed, and even when fixed, does that free the memory at all for now-unused elements?</p>
  
  <p>A little context : This array is the central data set of my module, and it can be heavy. It will live as long as the module lives. And there's no need to carry dead weight all this time. This is the very first thing that is done - figuring which segment of the data set has to be at all analyzed, and trimming and dumping the rest forever, never to use it again (until the next cycle where we get a fresh array with possibily a compeltely different size).</p>