Created
February 21, 2017 13:40
-
-
Save nathan-russell/a6c154ae18d2a5cc8dcc3af06da01ea6 to your computer and use it in GitHub Desktop.
http://stackoverflow.com/questions/42363850/template-for-class-returning-elements-of-rcppvectorrtype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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