@@ -61,7 +61,7 @@ bibliography: Rcpp
61
61
# watermark: false
62
62
63
63
# Customize footer, eg by referencing the vignette
64
- footer_contents : " Rcpp Vignette"
64
+ footer_contents : " Rcpp FAQ Vignette"
65
65
66
66
# Omit \pnasbreak at end
67
67
skip_final_break : true
@@ -1775,3 +1775,32 @@ redefines `TRUE` leading to bad interactions with the `Rboolean` enum type. A
1775
1775
very simple solution is to be more careful and conservative with ` #include `
1776
1776
files and a) have ` #include <mach/boolean.h> ` appear first and b) skip
1777
1777
the ` #include <Rinternals.h> ` as it is included by ` Rcpp.h ` anyway.
1778
+
1779
+ ## Can we grow Rcpp vectors like STL vectors via 'push* '
1780
+
1781
+ No. Use actual STL vectors instead. This has been stated clearly many times going
1782
+ back to the [ original announcement in Feb 2010] ( https://lists.r-forge.r-project.org/pipermail/rcpp-devel/2010-February/000410.html ) ,
1783
+ StackOverflow answers in [ Dec 2011] ( https://stackoverflow.com/a/8631853/143305 )
1784
+ and in [ Dec 2012] ( https://stackoverflow.com/a/13783044/143305 ) ,
1785
+ the rcpp-devel list in [ Jun 2013] ( https://lists.r-forge.r-project.org/pipermail/rcpp-devel/2013-June/006078.html ) ,
1786
+ another StackOverflow answer in [ Nov 2013] ( https://stackoverflow.com/a/19829440/143305 ) ,
1787
+ an early Rcpp Gallery post in [ Dec 2013] ( https://gallery.rcpp.org/articles/plyr-c-to-rcpp/ ) ,
1788
+ again on StackOverflow [ Dec 2014] ( https://stackoverflow.com/a/27585789/143305 ) , as well as in
1789
+ the 'Advanced R' [ first] ( http://adv-r.had.co.nz/Rcpp.html#stl ) and
1790
+ [ second] ( https://adv-r.hadley.nz/rcpp.html#stl ) editions.
1791
+ For emphasis, here is a quote from the [ rcpp-devel post] ( https://lists.r-forge.r-project.org/pipermail/rcpp-devel/2013-June/006078.html ) :
1792
+
1793
+ > Those are somehow cosmetic additions. The usual suggestion is not to
1794
+ > use push_front and push_back on Rcpp types.
1795
+ >
1796
+ > We use R's memory, and in R, resizing a vector means moving the data.
1797
+ > So if you push_back 3 times, you're moving the data 3 times.
1798
+ >
1799
+ > Using R own memory is the best ever decision we made in Rcpp. You can
1800
+ > always use your own data structures to accumulate data, perhaps using
1801
+ > stl types and then convert back to R types, which is something we make
1802
+ > easy to do.
1803
+
1804
+ Many code examples and packages show exactly that approach (as _ e.g._ discussed
1805
+ in the [ Rcpp Gallery post] ( https://gallery.rcpp.org/articles/plyr-c-to-rcpp/ ) ).
1806
+ Anybody who claims otherwise is (possibly intentionally) misleading.
0 commit comments