title: C++11 dynamic multidimensional array of any type using vector/initilizer list
body: <p>How do you create a multidimensional array (matrix) whose dimensions are determined at runtime.</p>
  
  <p>The best way seems to be to take a vector of dimensions for construction and also a vector of offsets to access individual elements</p>
  
  <p>This will also allow using initializer lists:</p>
  
  <p>This should take a matrix of types determined at compile time, so templates make sense</p>
  
  <p>C++11 features should be used as appropriate, bonus points for lambdas</p>
  
  <p>Example usage:</p>
  
  <pre><code>int main(int, char **)
  {
          static const std::size_t d1{2};
          static const std::size_t d2{3};
          static const std::size_t d3{4};
          multi_vec&lt;std::size_t&gt; q({d1,d2,d3});
  
          for (std::size_t i1=0; i1 &lt; d1; ++i1)
                  for (std::size_t i2=0; i2 &lt; d2; ++i2)
                          for (std::size_t i3=0; i3 &lt; d3; ++i3)
                                  q[{i1,i2,i3}]=foo(i1,i2,i3);
  
          for (std::size_t i1=0; i1 &lt; d1; ++i1)
                  for (std::size_t i2=0; i2 &lt; d2; ++i2)
                          for (std::size_t i3=0; i3 &lt; d3; ++i3)
                                  std::cout &lt;&lt; "{"
                                          &lt;&lt; i1 &lt;&lt; ","
                                          &lt;&lt; i2 &lt;&lt; ","
                                          &lt;&lt; i3 &lt;&lt; "}=&gt; "
                                          &lt;&lt; foo(i1,i2,i3) &lt;&lt; "=="
                                          &lt;&lt; q[{i1,i2,i3}]
                                          &lt;&lt; ((foo(i1,i2,i3) == q[{i1,i2,i3}])
                                                ? " good" : " ERROR")
                                  &lt;&lt; std::endl;
  };
  </code></pre>