|
2 | 2 | // |
3 | 3 | // algorithm.h: Rcpp R/C++ interface class library -- data frames |
4 | 4 | // |
5 | | -// Copyright (C) 2016 - 2017 Daniel C. Dillon |
| 5 | +// Copyright (C) 2016 - 2024 Daniel C. Dillon |
| 6 | +// Copyright (C) 2025 Daniel C. Dillon and Iñaki Ucar |
6 | 7 | // |
7 | 8 | // This file is part of Rcpp. |
8 | 9 | // |
|
22 | 23 | #ifndef Rcpp__Algorithm_h |
23 | 24 | #define Rcpp__Algorithm_h |
24 | 25 |
|
25 | | -#if __cplusplus >= 201103L || __INTEL_CXX11_MODE__ == 1 |
26 | | -# define RCPP_CONSTEXPR_FUNC constexpr |
27 | | -# define RCPP_CONSTEXPR_VAR constexpr |
28 | | -#else |
29 | | -# define RCPP_CONSTEXPR_FUNC |
30 | | -# define RCPP_CONSTEXPR_VAR const |
31 | | -#endif |
32 | | - |
33 | 26 | namespace Rcpp { |
34 | 27 | namespace algorithm { |
35 | 28 |
|
@@ -167,29 +160,29 @@ namespace helpers { |
167 | 160 | template<> |
168 | 161 | struct rtype_helper< double > { |
169 | 162 | typedef double type; |
170 | | - static RCPP_CONSTEXPR_VAR int RTYPE = REALSXP; |
| 163 | + static constexpr int RTYPE = REALSXP; |
171 | 164 | static inline double NA() { return NA_REAL; } |
172 | | - static inline RCPP_CONSTEXPR_FUNC double ZERO() { return 0.0; } |
173 | | - static inline RCPP_CONSTEXPR_FUNC double ONE() { return 1.0; } |
| 165 | + static inline constexpr double ZERO() { return 0.0; } |
| 166 | + static inline constexpr double ONE() { return 1.0; } |
174 | 167 | }; |
175 | 168 |
|
176 | 169 | template<> |
177 | 170 | struct rtype_helper< int > { |
178 | 171 | typedef int type; |
179 | | - static RCPP_CONSTEXPR_VAR int RTYPE = INTSXP; |
| 172 | + static constexpr int RTYPE = INTSXP; |
180 | 173 | static inline int NA() { return NA_INTEGER; } |
181 | | - static inline RCPP_CONSTEXPR_FUNC int ZERO() { return 0; } |
182 | | - static inline RCPP_CONSTEXPR_FUNC int ONE() { return 1; } |
| 174 | + static inline constexpr int ZERO() { return 0; } |
| 175 | + static inline constexpr int ONE() { return 1; } |
183 | 176 | }; |
184 | 177 |
|
185 | 178 | template< typename T > |
186 | 179 | struct rtype { |
187 | 180 | typedef typename rtype_helper< typename ctype< T >::type >::type type; |
188 | 181 | typedef rtype_helper< typename ctype< T >::type > helper_type; |
189 | | - static RCPP_CONSTEXPR_VAR int RTYPE = helper_type::RTYPE; |
| 182 | + static constexpr int RTYPE = helper_type::RTYPE; |
190 | 183 | static inline T NA() { return helper_type::NA(); } |
191 | | - static inline RCPP_CONSTEXPR_FUNC T ZERO() { return helper_type::ZERO(); } |
192 | | - static inline RCPP_CONSTEXPR_FUNC T ONE() { return helper_type::ONE(); } |
| 184 | + static inline constexpr T ZERO() { return helper_type::ZERO(); } |
| 185 | + static inline constexpr T ONE() { return helper_type::ONE(); } |
193 | 186 | }; |
194 | 187 |
|
195 | 188 | struct log { |
@@ -483,7 +476,4 @@ void sqrt(InputIterator begin, InputIterator end, OutputIterator out) { |
483 | 476 | } // namespace algorithm |
484 | 477 | } // namespace Rcpp |
485 | 478 |
|
486 | | -#undef RCPP_CONSTEXPR_FUNC |
487 | | -#undef RCPP_CONSTEXPR_VAR |
488 | | - |
489 | 479 | #endif |
0 commit comments