title: How can I use a std::valarray to store/manipulate a contiguous 2D array?
body: <p>How can I use a <code>std::valarray</code> to store/manipulate a 2D array?</p>
  
  <p>I'd like to see an example of a 2D array with elements accessed by row/column indices. Something like this pseudo code:</p>
  
  <pre><code>matrix(i,j) = 42;
  </code></pre>
  
  <p>An example of how to initialize such an array would also be nice.</p>
  
  <p>I'm already aware of Boost.MultiArray, Boost.uBlas, and Blitz++.</p>
  
  <p>Feel free to answer why I shouldn't use valarray for my use case. However, I want the memory for the multidimensional array to be a contiguous (columns x rows) block. No Java-style nested arrays.</p>