We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c750a29 + 6c24b84 commit 47ed3feCopy full SHA for 47ed3fe
inst/include/Rcpp/r_cast.h
@@ -135,8 +135,21 @@ namespace Rcpp{
135
136
} // namespace internal
137
138
- template <int TARGET> SEXP r_cast( SEXP x) {
139
- return (TYPEOF(x)== TARGET) ? x : internal::r_true_cast<TARGET>(x) ;
+ template <int TARGET> SEXP r_cast(SEXP x) {
+ if (TYPEOF(x) == TARGET) {
140
+ return x;
141
+ } else {
142
+ #ifndef RCPP_DONT_WARN_ON_COERCE
143
+ Shield<SEXP> result( internal::r_true_cast<TARGET>(x) );
144
+ Rf_warning("coerced object from '%s' to '%s'",
145
+ CHAR(Rf_type2str(TYPEOF(x))),
146
+ CHAR(Rf_type2str(TARGET))
147
+ );
148
+ return result;
149
+ #else
150
+ return internal::r_true_cast<TARGET>(x);
151
+ #endif
152
+ }
153
}
154
155
} // namespace Rcpp
0 commit comments