@@ -137,7 +137,7 @@ high-level \proglang{R} syntax in \proglang{C++}. Hence, with \sugar, the
137137\proglang{C++} version of ` foo ` now becomes:
138138
139139``` cpp
140- Rcpp::NumericVector foo (Rcpp::NumericVector x,
140+ Rcpp::NumericVector foo (Rcpp::NumericVector x,
141141 Rcpp::NumericVector y) {
142142 return ifelse(x < y, x * x, -(y * y));
143143}
@@ -308,7 +308,7 @@ length. Each element of the result expression evaluates to `TRUE` if
308308the corresponding input is a missing value, or ` FALSE ` otherwise.
309309
310310``` cpp
311- IntegerVector x =
311+ IntegerVector x =
312312 IntegerVector::create (0, 1, NA_INTEGER, 3);
313313
314314is_na(x)
@@ -322,7 +322,7 @@ Given a sugar expression of any type, `seq_along` creates an
322322integer sugar expression whose values go from 1 to the size of the input.
323323
324324```cpp
325- IntegerVector x =
325+ IntegerVector x =
326326 IntegerVector::create( 0, 1, NA_INTEGER, 3 );
327327
328328IntegerVector y = seq_along(x);
@@ -337,7 +337,7 @@ second expression, since the abstract syntax tree is built at compile time.
337337
338338### seq_len
339339
340- ` seq_len ` creates an integer sugar expression whose
340+ ` seq_len ` creates an integer sugar expression whose
341341\ith\ element expands to ` i ` . ` seq_len ` is particularly useful in
342342conjunction with ` sapply ` and ` lapply ` .
343343
@@ -411,7 +411,7 @@ called `result_type`
411411
412412```cpp
413413template <typename T>
414- struct square : std::unary_function<T, T > {
414+ struct square : std::function<T(T) > {
415415 T operator()(const T& x){
416416 return x * x;
417417 }
@@ -491,9 +491,9 @@ beta, binom, cauchy, chisq, exp, f, gamma, geom, hyper, lnorm, logis, nbeta,
491491nbinom, nbinom_mu, nchisq, nf, norm, nt, pois, t, unif, and weibull.
492492
493493Note that the parameterization used in these sugar functions may differ between
494- the top-level functions exposed in an \proglang{R} session. For example,
494+ the top-level functions exposed in an \proglang{R} session. For example,
495495the internal \code{rexp} is parameterized by \code{scale},
496- whereas the R-level \code{stats::rexp} is parameterized by \code{rate}.
496+ whereas the R-level \code{stats::rexp} is parameterized by \code{rate}.
497497Consult \href{http://cran.r-project.org/doc/manuals/r-release/R-exts.html#Distribution-functions}{Distribution Functions}
498498for more details on the parameterization used for these sugar functions.
499499
@@ -568,13 +568,13 @@ is given here:
568568template <int RTYPE, bool na, typename VECTOR>
569569class VectorBase {
570570public:
571- struct r_type :
571+ struct r_type :
572572 traits::integral_constant<int,RTYPE>{};
573573 struct can_have_na :
574574 traits::integral_constant<bool,na>{};
575-
576- typedef typename
577- traits::storage_type<RTYPE>::type
575+
576+ typedef typename
577+ traits::storage_type<RTYPE>::type
578578 stored_type;
579579
580580 VECTOR& get_ref(){
@@ -586,18 +586,18 @@ public:
586586 this)->operator[](i);
587587 }
588588
589- inline int size() const {
589+ inline int size() const {
590590 return static_cast<const VECTOR*>(
591- this)->size();
591+ this)->size();
592592 }
593593
594594 /* definition ommited here */
595595 class iterator;
596596
597- inline iterator begin() const {
598- return iterator(*this, 0);
597+ inline iterator begin() const {
598+ return iterator(*this, 0);
599599 }
600- inline iterator end() const {
600+ inline iterator end() const {
601601 return iterator(*this, size());
602602 }
603603}
@@ -633,27 +633,27 @@ the template class `Rcpp::sugar::Sapply` is given below:
633633template <int RTYPE, bool NA,
634634 typename T, typename Function>
635635class Sapply : public VectorBase <
636- Rcpp::traits::r_sexptype_traits< typename
636+ Rcpp::traits::r_sexptype_traits< typename
637637 ::Rcpp::traits::result_of<Function>::type
638638 >::rtype,
639639 true,
640640 Sapply<RTYPE, NA, T, Function>
641641> {
642642public:
643- typedef typename
643+ typedef typename
644644 ::Rcpp::traits::result_of<Function >::type;
645-
645+
646646 const static int RESULT_R_TYPE =
647647 Rcpp::traits::r_sexptype_traits<
648648 result_type>::rtype;
649-
649+
650650 typedef Rcpp::VectorBase<RTYPE,NA,T> VEC;
651-
652- typedef typename
651+
652+ typedef typename
653653 Rcpp::traits::r_vector_element_converter<
654654 RESULT_R_TYPE>::type
655655 converter_type;
656-
656+
657657 typedef typename Rcpp::traits::storage_type<
658658 RESULT_R_TYPE>::type STORAGE;
659659
@@ -663,9 +663,9 @@ public:
663663 inline STORAGE operator []( int i ) const {
664664 return converter_type::get(fun(vec[i]));
665665 }
666-
667- inline int size() const {
668- return vec.size();
666+
667+ inline int size() const {
668+ return vec.size();
669669 }
670670
671671private:
@@ -675,13 +675,13 @@ private:
675675
676676// sugar
677677
678- template <int RTYPE, bool _NA_,
678+ template <int RTYPE, bool _NA_,
679679 typename T, typename Function >
680680inline sugar::Sapply<RTYPE, _NA_, T, Function>
681681sapply (const Rcpp::VectorBase<RTYPE,_ NA_ ,T>& t,
682682 Function fun) {
683-
684- return
683+
684+ return
685685 sugar::Sapply<RTYPE,_NA_,T,Function>(t, fun);
686686}
687687```
@@ -703,8 +703,8 @@ template class queries the template argument via the `Rcpp::traits::result_of`
703703template.
704704
705705```cpp
706- typedef typename
707- ::Rcpp::traits::result_of<Function>::type
706+ typedef typename
707+ ::Rcpp::traits::result_of<Function>::type
708708 result_type;
709709```
710710
@@ -717,7 +717,7 @@ struct result_of{
717717 typedef typename T::result_type type;
718718};
719719
720- template <typename RESULT_TYPE,
720+ template <typename RESULT_TYPE,
721721 typename INPUT_TYPE>
722722struct result_of<RESULT_TYPE (*)(INPUT_TYPE)> {
723723 typedef RESULT_TYPE type;
@@ -762,7 +762,7 @@ of a `REALSXP` expression is `double`.
762762
763763``` cpp
764764typedef typename
765- Rcpp::traits::storage_type<RESULT_R_TYPE>::type
765+ Rcpp::traits::storage_type<RESULT_R_TYPE>::type
766766 STORAGE;
767767```
768768
@@ -785,7 +785,7 @@ template <int RTYPE, bool NA,
785785 typename T, typename Function>
786786class Sapply : public VectorBase <
787787 Rcpp::traits::r_sexptype_traits<
788- typename
788+ typename
789789 ::Rcpp::traits::result_of<Function>::type
790790 >::rtype,
791791 true,
@@ -799,13 +799,13 @@ is the manifestation of the _CRTP_.
799799
800800### Constructor
801801
802-
802+
803803The constructor of the `Sapply` class template is straightforward, it
804804simply consists of holding the reference to the input expression and the
805805function.
806806
807807```cpp
808- Sapply(const VEC& vec_, Function fun_):
808+ Sapply(const VEC& vec_, Function fun_):
809809 vec(vec_), fun(fun_){}
810810
811811private:
@@ -825,8 +825,8 @@ and the converter. Both these methods are inline to maximize performance:
825825inline STORAGE operator [](int i) const {
826826 return converter_type::get(fun(vec[i]));
827827}
828- inline int size () const {
829- return vec.size();
828+ inline int size () const {
829+ return vec.size();
830830}
831831```
832832
0 commit comments