Should I prefer Rcpp::NumericVector over std::vector? : <p>Is there any reason why I should prefer <code>Rcpp::NumericVector</code> over <code>std::vector&lt;double&gt;</code>?</p>

<p>For example, the two functions below</p>

<pre><code>// [[Rcpp::export]]
Rcpp::NumericVector foo(const Rcpp::NumericVector&amp; x) {
  Rcpp::NumericVector tmp(x.length());
  for (int i = 0; i &lt; x.length(); i++)
    tmp[i] = x[i] + 1.0;
  return tmp;
}

// [[Rcpp::export]]
std::vector&lt;double&gt; bar(const std::vector&lt;double&gt;&amp; x) {
  std::vector&lt;double&gt; tmp(x.size());
  for (int i = 0; i &lt; x.size(); i++)
    tmp[i] = x[i] + 1.0;
  return tmp;
}
</code></pre>

<p>Are equivalent when considering their working and benchmarked performance. I understand that Rcpp offers sugar and vectorized operations, but if it is only about taking R's vector as input and returning vector as output, then would there be any difference which one of those I use? Can using <code>std::vector&lt;double&gt;</code> lead to any possible problems when interacting with R?</p>
