1
- // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
1
+ // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2
2
/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
3
3
//
4
4
// r_vector.h: Rcpp R/C++ interface class library -- information about R vectors
5
5
//
6
- // Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
6
+ // Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
7
7
//
8
8
// This file is part of Rcpp.
9
9
//
@@ -27,63 +27,62 @@ namespace Rcpp{
27
27
namespace internal {
28
28
29
29
template <int RTYPE>
30
- typename Rcpp::traits::storage_type<RTYPE>::type* r_vector_start (SEXP x){
31
- typedef typename Rcpp::traits::storage_type<RTYPE>::type* pointer ;
32
- return reinterpret_cast <pointer>( dataptr (x) ) ;
30
+ typename Rcpp::traits::storage_type<RTYPE>::type* r_vector_start (SEXP x) {
31
+ typedef typename Rcpp::traits::storage_type<RTYPE>::type* pointer;
32
+ return reinterpret_cast <pointer>(dataptr (x)) ;
33
33
}
34
34
35
35
/* *
36
36
* The value 0 statically casted to the appropriate type for
37
37
* the given SEXP type
38
38
*/
39
- template <int RTYPE,typename CTYPE>
40
- inline CTYPE get_zero (){
41
- return static_cast <CTYPE>(0 ) ;
42
- }
39
+ template <int RTYPE,typename CTYPE> // #nocov start
40
+ inline CTYPE get_zero () {
41
+ return static_cast <CTYPE>(0 );
42
+ } // #nocov end
43
43
44
44
45
45
/* *
46
46
* Specialization for Rcomplex
47
47
*/
48
48
template <>
49
49
inline Rcomplex get_zero<CPLXSXP,Rcomplex>(){
50
- Rcomplex x ;
51
- x.r = 0.0 ;
52
- x.i = 0.0 ;
53
- return x ;
50
+ Rcomplex x;
51
+ x.r = 0.0 ;
52
+ x.i = 0.0 ;
53
+ return x;
54
54
}
55
55
56
56
/* *
57
57
* Initializes a vector of the given SEXP type. The template fills the
58
58
* vector with the value 0 of the appropriate type, for example
59
59
* an INTSXP vector is initialized with (int)0, etc...
60
60
*/
61
- template <int RTYPE> void r_init_vector (SEXP x){
62
- typedef typename ::Rcpp::traits::storage_type<RTYPE>::type CTYPE ;
63
- CTYPE* start=r_vector_start<RTYPE>(x) ;
64
- std::fill ( start, start + Rf_xlength (x), get_zero<RTYPE,CTYPE>() ) ;
65
- }
61
+ template <int RTYPE> void r_init_vector (SEXP x) { // #nocov start
62
+ typedef typename ::Rcpp::traits::storage_type<RTYPE>::type CTYPE;
63
+ CTYPE* start=r_vector_start<RTYPE>(x);
64
+ std::fill (start, start + Rf_xlength (x), get_zero<RTYPE,CTYPE>()) ;
65
+ } // #nocov end
66
66
/* *
67
67
* Initializes a generic vector (VECSXP). Does nothing since
68
68
* R already initializes all elements to NULL
69
69
*/
70
70
template <>
71
- inline void r_init_vector<VECSXP>(SEXP /* x*/ ){}
71
+ inline void r_init_vector<VECSXP>(SEXP /* x*/ ) {}
72
72
73
73
/* *
74
74
* Initializes an expression vector (EXPRSXP). Does nothing since
75
75
* R already initializes all elements to NULL
76
76
*/
77
77
template <>
78
- inline void r_init_vector<EXPRSXP>(SEXP /* x*/ ){}
78
+ inline void r_init_vector<EXPRSXP>(SEXP /* x*/ ) {}
79
79
80
80
/* *
81
81
* Initializes a character vector (STRSXP). Does nothing since
82
82
* R already initializes all elements to ""
83
83
*/
84
84
template <>
85
- inline void r_init_vector<STRSXP>(SEXP /* x*/ ){}
86
-
85
+ inline void r_init_vector<STRSXP>(SEXP /* x*/ ) {}
87
86
88
87
89
88
/* *
@@ -104,36 +103,31 @@ class Sort_is_not_allowed_for_this_type;
104
103
* Specialization for CPLXSXP, INTSXP, LGLSXP, REALSXP, and STRSXP
105
104
*/
106
105
template <>
107
- class Sort_is_not_allowed_for_this_type <CPLXSXP>
108
- {
106
+ class Sort_is_not_allowed_for_this_type <CPLXSXP> {
109
107
public:
110
108
static void do_nothing () {}
111
109
};
112
110
113
111
template <>
114
- class Sort_is_not_allowed_for_this_type <INTSXP>
115
- {
112
+ class Sort_is_not_allowed_for_this_type <INTSXP> {
116
113
public:
117
114
static void do_nothing () {}
118
115
};
119
116
120
117
template <>
121
- class Sort_is_not_allowed_for_this_type <LGLSXP>
122
- {
118
+ class Sort_is_not_allowed_for_this_type <LGLSXP> {
123
119
public:
124
120
static void do_nothing () {}
125
121
};
126
122
127
123
template <>
128
- class Sort_is_not_allowed_for_this_type <REALSXP>
129
- {
124
+ class Sort_is_not_allowed_for_this_type <REALSXP> {
130
125
public:
131
126
static void do_nothing () {}
132
127
};
133
128
134
129
template <>
135
- class Sort_is_not_allowed_for_this_type <STRSXP>
136
- {
130
+ class Sort_is_not_allowed_for_this_type <STRSXP> {
137
131
public:
138
132
static void do_nothing () {}
139
133
};
0 commit comments