-
Notifications
You must be signed in to change notification settings - Fork 12
const-ness problem with Dots + .promise() call #213
Copy link
Copy link
Open
Description
Ie, with the code from http://stackoverflow.com/questions/24590946/passing-many-argumentes-by-ellipsis-in-rcpp:
#include <Rcpp11>
List force_dots( const Dots& dots ){
R_xlen_t n = dots.size();
List out(n) ;
for( int i=0; i<n; i++){
out[i] = Rcpp_eval( dots.promise(i), dots.environment(i)) ;
}
return out ;
}
// [[export]]
List dots_example(NumericVector x, Dots dots){
int n = dots.size() ;
List args = force_dots(dots) ;
return args ;
}
/*** R
dots_example(1:10, "e" )
# [[1]]
# [1] "e"
*/I get:
> attributes::sourceCpp("~/Desktop/test.cpp")
file663be25ca6f.cpp:7:25: error: member function 'promise' not viable: 'this' argument has type 'const Dots' (aka 'const Dots_Impl<Rcpp::NoProtectStorage>'), but function is not marked const
out[i] = Rcpp_eval( dots.promise(i), dots.environment(i)) ;
^~~~
/Users/kevinushey/Library/R/3.2/library/Rcpp11/include/Rcpp/Dots.h:26:25: note: 'promise' declared here
inline Promise& promise(int i) {
^
1 error generated.I imagine you ran this code and it worked fine so I am a bit surprised. Maybe a compiler-specific issue?
kevinushey@Kevin-MBP:~/git/attributes$ clang++ -v
clang version 3.5.0 (trunk 203549)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels