Rcpp pass vector of length 0 (NULL) to cppfunction
<p>I have a <code>cppFunction</code> with a vector <code>ints</code> as input, e.g:</p>

<pre><code>library(Rcpp)
cppFunction('double test2(NumericVector ints) {
            return 42;
            }')
</code></pre>

<p>The output is correct if passing a vector of length at least 1:</p>

<pre><code>&gt; test2(1)
[1] 42
&gt; test2(1:10)
[1] 42
</code></pre>

<p>For input of length 0 however I get: </p>

<pre><code>&gt; test2(c())
Error: not compatible with requested type
</code></pre>

<p>Is there any way to pass a vector of length 0 or larger to my function? I.e. my expected output is: </p>

<pre><code>&gt; test2_expectedoutput(c())
[1] 42
</code></pre>

<p>I know I could control for this in R by checking in R first and calling a different version of the function but would like to avoid this. I expect there is some easy solution out there since within cpp I could also have a <code>NumericVector</code> of length 0 if I understand correctly what <code>NumericVector zero;</code> does. The only related question I could find was <a href="https://stackoverflow.com/questions/25658225/how-to-return-rs-null-in-rcpp-code">this on how to return a NULL object from within a Rcpp function to R</a>. </p>