Skip to content

Instantly share code, notes, and snippets.

@nathan-russell
Created February 21, 2017 13:40
Show Gist options
  • Save nathan-russell/a6c154ae18d2a5cc8dcc3af06da01ea6 to your computer and use it in GitHub Desktop.
Save nathan-russell/a6c154ae18d2a5cc8dcc3af06da01ea6 to your computer and use it in GitHub Desktop.
template <int RTYPE>
class MyNumVec {
public:
typedef Rcpp::Vector<RTYPE> vec_t;
typedef typename Rcpp::traits::storage_type<RTYPE>::type storage_t;
private:
const vec_t& x;
public:
MyNumVec(const vec_t& y)
: x(y)
{}
storage_t operator[](int i) const
{ return x[i]; }
operator vec_t() const
{ return x; }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment