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

Method newInstance

inst/include/Rcpp/module/class.h:130–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128 }
129
130 SEXP newInstance( SEXP* args, int nargs ){
131 BEGIN_RCPP
132 signed_constructor_class* p ;
133 size_t n = constructors.size() ;
134 for( size_t i=0; i<n; i++ ){
135 p = constructors[i];
136 bool ok = (p->valid)(args, nargs) ;
137 if( ok ){
138 Class* ptr = p->ctor->get_new( args, nargs ) ;
139 return XP( ptr, true ) ;
140 }
141 }
142
143 signed_factory_class* pfact ;
144 n = factories.size() ;
145 for( size_t i=0; i<n; i++){
146 pfact = factories[i] ;
147 bool ok = (pfact->valid)(args, nargs) ;
148 if( ok ){
149 Class* ptr = pfact->fact->get_new( args, nargs ) ;
150 return XP( ptr, true ) ;
151 }
152 }
153
154 throw std::range_error( "no valid constructor available for the argument list" ) ;
155 END_RCPP
156 }
157
158 bool has_default_constructor(){
159 size_t n = constructors.size() ;

Callers 1

class__newInstanceFunction · 0.45

Calls 2

sizeMethod · 0.45
get_newMethod · 0.45

Tested by

no test coverage detected