title: Rcpp and int64 NA value
body: <p>How can I pass an NA value from Rcpp to R in a 64 bit vector?</p>
  
  <p>My first approach would be:</p>
  
  <pre><code>// [[Rcpp::export]]                                     
  Rcpp::NumericVector foo() {
    Rcpp::NumericVector res(2);
  
    int64_t val = 1234567890123456789;
    std::memcpy(&amp;(res[0]), &amp;(val), sizeof(double));
    res[1] = NA_REAL;
  
    res.attr("class") = "integer64";
    return res;
  }
  </code></pre>
  
  <p>But it yields </p>
  
  <pre><code>#&gt; foo()
  integer64
  [1] 1234567890123456789 9218868437227407266
  </code></pre>
  
  <p>I need to get</p>
  
  <pre><code>#&gt; foo()
  integer64
  [1] 1234567890123456789 &lt;NA&gt;
  </code></pre>