|
23 | 23 | #define Rcpp__Algorithm_h
|
24 | 24 |
|
25 | 25 | #if __cplusplus >= 201103L || __INTEL_CXX11_MODE__ == 1
|
26 |
| -# define RCPP_CONSTEXPR constexpr |
| 26 | +# define RCPP_CONSTEXPR_FUNC constexpr |
| 27 | +# define RCPP_CONSTEXPR_VAR constexpr |
27 | 28 | #else
|
28 |
| -# define RCPP_CONSTEXPR const |
| 29 | +# define RCPP_CONSTEXPR_FUNC |
| 30 | +# define RCPP_CONSTEXPR_VAR const |
29 | 31 | #endif
|
30 | 32 |
|
31 | 33 | namespace Rcpp {
|
@@ -160,41 +162,34 @@ namespace helpers {
|
160 | 162 |
|
161 | 163 | template< typename T >
|
162 | 164 | struct rtype_helper {
|
163 |
| - /* |
164 |
| - typedef T type; |
165 |
| - static RCPP_CONSTEXPR int RTYPE = REALSXP; |
166 |
| - static inline double NA() { return NA_REAL; } |
167 |
| - static inline RCPP_CONSTEXPR double ZERO() { return 0.0; } |
168 |
| - static inline RCPP_CONSTEXPR double ONE() { return 1.0; } |
169 |
| - */ |
170 | 165 | };
|
171 | 166 |
|
172 | 167 | template<>
|
173 | 168 | struct rtype_helper< double > {
|
174 | 169 | typedef double type;
|
175 |
| - static RCPP_CONSTEXPR int RTYPE = REALSXP; |
| 170 | + static RCPP_CONSTEXPR_VAR int RTYPE = REALSXP; |
176 | 171 | static inline double NA() { return NA_REAL; }
|
177 |
| - static inline RCPP_CONSTEXPR double ZERO() { return 0.0; } |
178 |
| - static inline RCPP_CONSTEXPR double ONE() { return 1.0; } |
| 172 | + static inline RCPP_CONSTEXPR_FUNC double ZERO() { return 0.0; } |
| 173 | + static inline RCPP_CONSTEXPR_FUNC double ONE() { return 1.0; } |
179 | 174 | };
|
180 | 175 |
|
181 | 176 | template<>
|
182 | 177 | struct rtype_helper< int > {
|
183 | 178 | typedef int type;
|
184 |
| - static RCPP_CONSTEXPR int RTYPE = INTSXP; |
| 179 | + static RCPP_CONSTEXPR_VAR int RTYPE = INTSXP; |
185 | 180 | static inline int NA() { return NA_INTEGER; }
|
186 |
| - static inline RCPP_CONSTEXPR int ZERO() { return 0; } |
187 |
| - static inline RCPP_CONSTEXPR int ONE() { return 1; } |
| 181 | + static inline RCPP_CONSTEXPR_FUNC int ZERO() { return 0; } |
| 182 | + static inline RCPP_CONSTEXPR_FUNC int ONE() { return 1; } |
188 | 183 | };
|
189 | 184 |
|
190 | 185 | template< typename T >
|
191 | 186 | struct rtype {
|
192 | 187 | typedef typename rtype_helper< typename ctype< T >::type >::type type;
|
193 | 188 | typedef rtype_helper< typename ctype< T >::type > helper_type;
|
194 |
| - static RCPP_CONSTEXPR int RTYPE = helper_type::RTYPE; |
| 189 | + static RCPP_CONSTEXPR_VAR int RTYPE = helper_type::RTYPE; |
195 | 190 | static inline T NA() { return helper_type::NA(); }
|
196 |
| - static inline RCPP_CONSTEXPR T ZERO() { return helper_type::ZERO(); } |
197 |
| - static inline RCPP_CONSTEXPR T ONE() { return helper_type::ONE(); } |
| 191 | + static inline RCPP_CONSTEXPR_FUNC T ZERO() { return helper_type::ZERO(); } |
| 192 | + static inline RCPP_CONSTEXPR_FUNC T ONE() { return helper_type::ONE(); } |
198 | 193 | };
|
199 | 194 |
|
200 | 195 | struct log {
|
@@ -488,6 +483,7 @@ void sqrt(InputIterator begin, InputIterator end, OutputIterator out) {
|
488 | 483 | } // namespace algorithm
|
489 | 484 | } // namespace Rcpp
|
490 | 485 |
|
491 |
| -#undef RCPP_CONSTEXPR |
| 486 | +#undef RCPP_CONSTEXPR_FUNC |
| 487 | +#undef RCPP_CONSTEXPR_VAR |
492 | 488 |
|
493 | 489 | #endif
|
0 commit comments