Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork219
Add assignment operator to DimNameProxy#339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -56,6 +56,31 @@ namespace internal{ | ||
| return *this; | ||
| } | ||
| inline DimNameProxy& operator=(const DimNameProxy& other) { | ||
| SEXP dim = Rf_getAttrib(data_, R_DimSymbol); | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This should probably have a NULL check (same with older implementation) | ||
| if (INTEGER(dim)[dim_] != INTEGER(dim)[other.dim_]) { | ||
| std::stringstream s; | ||
| s << "dimension extent is '" | ||
| << INTEGER(dim)[dim_] | ||
| << "' while length of names is '" | ||
| << INTEGER(dim)[other.dim_] | ||
| << "'"; | ||
| stop(s.str()); | ||
| } | ||
| SEXP dimnames = Rf_getAttrib(data_, R_DimNamesSymbol); | ||
| SEXP dims = Rf_getAttrib(data_, R_DimSymbol); | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. It looks like you already retrieved this above with EDIT: I see now the interface is mostly copied from the other Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. And while you're there, now that | ||
| SEXP other_dimnames = SEXP(other); | ||
| if (Rf_isNull(dimnames)) { | ||
| Shield<SEXP> new_dimnames(Rf_allocVector(VECSXP, Rf_length(dims))); | ||
| SET_VECTOR_ELT(new_dimnames, dim_, other_dimnames); | ||
| Rf_setAttrib(data_, R_DimNamesSymbol, new_dimnames); | ||
| } else { | ||
| SET_VECTOR_ELT(dimnames, dim_, other_dimnames); | ||
| } | ||
| return *this; | ||
| } | ||
| inline operator SEXP() const { | ||
| SEXP dimnames = Rf_getAttrib(data_, R_DimNamesSymbol); | ||
| return Rf_isNull(dimnames) ? (R_NilValue) : (VECTOR_ELT(dimnames, dim_)); | ||