Passing uint64_t from C++ to R: Hilbert Mapping - xy2d function
Because we write C++, there's no reason to declare (most) variables at the beginning of the scope of your function. For example, all of d, rx, ry and s have been declared for no reason if you happen to throw and exit the function.
You don't need s after the for-loop, so it should be local to the loop only. Similar for rx and ry.
Make use of shorthand operators like /= and +=.
You can make v const and initialize it with a suitable constructor, in this case std::vector&lt;uint64_t&gt; v(1, d); initializes v to hold one element equal to d. But really, as it stands, I see no point in using an array here if you just have a single value (I suspect your example is incomplete and not representative of your real use case, which is a shame).
Because len can be const, make it const. This protects from unintended errors and possibly allows the compiler to perform more optimizations.
As a general comment, avoid saying using namespace std;, it's not good for you.
I don't know the interface of Rcpp::NumericVector, but might you initialize it directly in the spirit of const Rcpp::NumericVector nn(v.cbegin(), v.cend()), for instance?