title: Dealing with subvectors in costant time
body: <p>I'm implementing an algorithm and I need to be really efficient. My algorithm works on a set of equal and constant size vectors of bools, and I would like to keep them consecutive in memory to avoid cache misses. Since it's used a lot of time, my solution at the moment is to concatenate all the vectors in the set in a unique bigger vector, before running the algorithm. This should make all the vectors consecutive in the memory, but give me another problem: I can't access anymore a  single vector that is in the set. Of course, I can use</p>
  <pre><code>vector&lt;bool&gt;(concatenation.begin()+i, concatenation.end()+i+vector_size)
  </code></pre>
  <p>but this would make a copy of the data, vanishing my original objective of optimizing performance. Ideally, I would like to have a function that returns me a <code>const vector&lt;vector_type&gt;&amp;</code> of the subvector, since I only need to read the content and not modify it during the algorithm execution.</p>
  <p>I'm open also to completely different solutions to do it, but if it is possible I would like to avoid using the iterators.</p>
  <p>I've also to say that the size of the vectors of bools is known at compile-time, so maybe an <code>array</code> would work, but I've read that they shouldn't be used because of they are a  wrapper to unsafe C arrays.</p>