MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / RCPP_MODULE

Function RCPP_MODULE

inst/tinytest/testRcppClass/src/stdVector.cpp:35–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33double vec_at(vec *obj, int i){ return obj->at(i) ; }
34
35RCPP_MODULE(stdVector){
36 using namespace Rcpp ;
37
38 // we expose the class std::vector<double> as "vec" on the R side
39 class_<vec>( "stdNumeric")
40
41 // exposing the default constructor
42 .constructor()
43
44 // exposing member functions
45 .method( "size", &vec::size)
46 .method( "max_size", &vec::max_size)
47 .method( "capacity", &vec::capacity)
48 .method( "empty", &vec::empty)
49 .method( "reserve", &vec::reserve)
50 .method( "pop_back", &vec::pop_back )
51 .method( "clear", &vec::clear )
52
53 // specifically exposing const member functions
54 .method( "back", &vec_back )
55 .method( "front", &vec_front )
56 .method( "at", &vec_at )
57 .method( "set", &vec_set )
58
59 // exposing free functions taking a std::vector<double>*
60 // as their first argument
61 .method( "assign", &vec_assign )
62 .method( "insert", &vec_insert )
63 .method( "as.vector", &vec_asR )
64 .method( "push_back", &vec_push_back )
65 .method( "resize", &vec_resize)
66
67 // special methods for indexing
68 // .method( "[[", &vec_at )
69 // .method( "[[<-", &vec_set )
70 ;
71}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected