Eigen - Map a const array to a dynamic vector
<p>I need to define a function that takes a <code>const</code> C array and maps it into an <code>Eigen</code> map. The following code gives me an error:</p>

<pre><code>double data[10] = {0.0};
typedef Eigen::Map&lt;Eigen::VectorXd&gt; MapVec;

MapVec fun(const double* data) {
  MapVec vec(data, n);
  return vec;
}
</code></pre>

<p>If I remove <code>const</code> from the function definition the code works fine. But is it possible to retain the <code>const</code> without any errors?</p>

<p>Thanks.</p>