File tree Expand file tree Collapse file tree 2 files changed +46
-46
lines changed
Expand file tree Collapse file tree 2 files changed +46
-46
lines changed Original file line number Diff line number Diff line change @@ -224,35 +224,35 @@ SEXP map_int_vector_double(){
224224 return wrap ( map ) ;
225225}
226226
227- // RCPP_EXPOSED_CLASS(Foo)
228- // class Foo{
229- // public:
230- // Foo() : x(0.0){}
231- // Foo( double x_ ) : x(x_){}
232- // double get() { return x ; }
233- // private:
234- // double x ;
235- // } ;
236- // RCPP_MODULE(mod){
237- // class_<Foo>("Foo")
238- // .constructor<double>()
239- // .method( "get", &Foo::get )
240- // ;
241- // }
242- //
243- // // [[Rcpp::export]]
244- // SEXP map_int_Foo(){
245- // std::map<int, Foo> map ;
246- // map[0] = Foo( 2 ) ;
247- // map[1] = Foo( 3 ) ;
248- // return wrap( map ) ;
249- // }
250- //
251- // // [[Rcpp::export]]
252- // SEXP vector_Foo(){
253- // std::vector<Foo> vec(2) ;
254- // vec[0] = Foo( 2 ) ;
255- // vec[1] = Foo( 3 ) ;
256- // return wrap(vec) ;
257- // }
227+ RCPP_EXPOSED_CLASS (Foo)
228+ class Foo{
229+ public:
230+ Foo () : x (0.0 ){}
231+ Foo ( double x_ ) : x (x_){}
232+ double get () { return x ; }
233+ private:
234+ double x ;
235+ } ;
236+ RCPP_MODULE (mod){
237+ class_<Foo>(" Foo" )
238+ .constructor <double >()
239+ .method ( " get" , &Foo::get )
240+ ;
241+ }
242+
243+ // [[Rcpp::export]]
244+ SEXP map_int_Foo (){
245+ std::map<int , Foo> map ;
246+ map[0 ] = Foo ( 2 ) ;
247+ map[1 ] = Foo ( 3 ) ;
248+ return wrap ( map ) ;
249+ }
250+
251+ // [[Rcpp::export]]
252+ SEXP vector_Foo (){
253+ std::vector<Foo> vec (2 ) ;
254+ vec[0 ] = Foo ( 2 ) ;
255+ vec[1 ] = Foo ( 3 ) ;
256+ return wrap (vec) ;
257+ }
258258
Original file line number Diff line number Diff line change @@ -167,21 +167,21 @@ test.wrap.map.int.vector_double <- function(){
167167 )
168168}
169169
170- # test.wrap.map.int.Foo <- function(){
171- # checkEquals(
172- # sapply( map_int_Foo(), function(.) .$get() ),
173- # c("0" = 2, "1" = 3 ),
174- # msg = "std::map<int, MODULE EXPOSED CLASS >"
175- # )
176- # }
177- #
178- # test.wrap.vector.Foo <- function(){
179- # checkEquals(
180- # sapply( vector_Foo(), function(.) .$get() ),
181- # c(2, 3),
182- # msg = "std::vector< MODULE EXPOSED CLASS >"
183- # )
184- # }
170+ test.wrap.map.int.Foo <- function (){
171+ checkEquals(
172+ sapply( map_int_Foo(), function (. ) . $ get() ),
173+ c(" 0" = 2 , " 1" = 3 ),
174+ msg = " std::map<int, MODULE EXPOSED CLASS >"
175+ )
176+ }
177+
178+ test.wrap.vector.Foo <- function (){
179+ checkEquals(
180+ sapply( vector_Foo(), function (. ) . $ get() ),
181+ c(2 , 3 ),
182+ msg = " std::vector< MODULE EXPOSED CLASS >"
183+ )
184+ }
185185
186186}
187187
You can’t perform that action at this time.
0 commit comments