title: Using colon (':') to access elements in an array in C++ (in Rcpp)
body: <p>I am trying to run the following code. Frankly I know C++ only little but I want to get the following function run. Can you help me run this silly example?</p>
  
  <pre><code>cppFunction(
    'NumericVector abc(int x, int x_end, NumericVector y)
    {
      NumericVector z;
      int x1 = x + x_end;
      z = y[x:x1];
      return(z);  
     }'
  )
  
  abc(3,c(0,1,10,100,1000,10000))
  </code></pre>
  
  <p>I see this ...</p>
  
  <p><em>error: expected ']' before ':' token</em></p>
  
  <p><strong>Update</strong>
  Sorry I forgot to mention that I need to generate a sequence of numbers from <code>x</code> to <code>x1</code>. The function <code>IntegerVector::create</code> only creates a variable with only <code>x</code> and <code>x1</code> not <code>x</code> though <code>x1</code>. The example I gave was trivial. I updated the example now. I need to do in <strong>C++</strong> what <code>seq()</code> does in <strong>R</strong></p>
  
  <p><strong>Solution based on the answer below (@SleuthEye)</strong></p>
  
  <pre><code>Rcpp::cppFunction(
    'NumericVector abc(int x, int x_end, NumericVector y)
    {
    NumericVector z;
    Range idx(x,x_end);
    z = y[idx];
    return(z);  
    }'
  )
  
  abc(3,5,c(0,1,10,100,1000,10000))
  [1]   100  1000 10000
  </code></pre>