Skip to content

Commit b0eb4c7

Browse files
committed
Switch to attributes (#56) and typos
1 parent 327d057 commit b0eb4c7

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

vignettes/Rcpp-extending.Rnw

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ These converters are often used implicitly, as in the following code chunk:
9191

9292
<<echo=FALSE>>=
9393
code <- '
94-
// we get a list from R
95-
List input(input_) ;
94+
#include <Rcpp.h>
95+
using namespace Rcpp;
96+
97+
// [[Rcpp::export]]
98+
List fx(List input){ // we get a list from R
9699
97100
// pull std::vector<double> from R list
98101
// this is achieved through an implicit call to Rcpp::as
@@ -103,7 +106,8 @@ std::vector<double> x = input["x"] ;
103106
return List::create(
104107
_["front"] = x.front(),
105108
_["back"] = x.back()
106-
) ;
109+
);
110+
}
107111
'
108112
writeLines( code, "code.cpp" )
109113
@
@@ -112,10 +116,7 @@ external_highlight( "code.cpp", type = "LATEX", doc = FALSE )
112116
@
113117

114118
<<>>=
115-
fx <- cxxfunction( signature( input_ = "list"),
116-
paste( readLines( "code.cpp" ), collapse = "\n" ),
117-
plugin = "Rcpp"
118-
)
119+
Rcpp::sourceCpp(file= "code.cpp")
119120
input <- list( x = seq(1, 10, by = 0.5) )
120121
fx( input )
121122
@
@@ -227,8 +228,6 @@ will attempt to use the constructor of the target class taking a \texttt{SEXP}.
227228
<<lang=cpp>>=
228229
#include <RcppCommon.h>
229230
230-
#include <RcppCommon.h>
231-
232231
class Foo{
233232
public:
234233
Foo() ;
@@ -237,18 +236,16 @@ class Foo{
237236
Foo(SEXP) ;
238237
}
239238
240-
#include <Rcpp.h>
241-
242239
243240
// this must appear after the specialization,
244241
// otherwise the specialization will not be seen by Rcpp types
245242
#include <Rcpp.h>
246243
@
247244

248-
\subsection{Non intrusive extension}
245+
\subsection{Non-intrusive extension}
249246

250247
It is also possible to fully specialize \texttt{Rcpp::as} to enable
251-
non intrusive implicit conversion capabilities.
248+
non-intrusive implicit conversion capabilities.
252249

253250
<<lang=cpp>>=
254251
#include <RcppCommon.h>

0 commit comments

Comments
 (0)