Skip to content

Commit 88b5f66

Browse files
committed
remove pre-C++11 paths based on __cplusplus checks
1 parent eaa119a commit 88b5f66

File tree

8 files changed

+25
-82
lines changed

8 files changed

+25
-82
lines changed

ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
* inst/include/Rcpp/exceptions/cpp11/exceptions.h: Removed
66
* inst/include/Rcpp/exceptions/cpp98/exceptions.h: Idem
77

8+
* src/attributes.cpp: Remove obsolete pre-C+11 paths based on __cplusplus
9+
define checks
10+
* inst/tinytest/cpp/sugar.cpp: Idem
11+
* inst/include/Rcpp/Language.h: Idem
12+
* inst/include/Rcpp/StringTransformer.h: Idem
13+
* inst/include/Rcpp/algorithm.h: Idem
14+
* inst/include/Rcpp/utils/tinyformat.h: Idem
15+
* inst/include/Rcpp/longlong.h: Idem, unconditional RCPP_HAS_LONG_LONG_TYPES
16+
817
2025-03-21 Dirk Eddelbuettel <[email protected]>
918

1019
* DESCRIPTION (Version, Date): Roll micro version and date

inst/include/Rcpp/Language.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,7 @@ namespace Rcpp{
186186
};
187187

188188
template <typename T, typename RESULT_TYPE = SEXP>
189-
#if __cplusplus < 201103L
190-
class unary_call : public std::unary_function<T,RESULT_TYPE> {
191-
#else
192189
class unary_call : public std::function<RESULT_TYPE(T)> {
193-
#endif
194190
public:
195191
unary_call( Language call_ ) : call(call_), proxy(call_,1) {}
196192
unary_call( Language call_, R_xlen_t index ) : call(call_), proxy(call_,index){}
@@ -207,11 +203,7 @@ namespace Rcpp{
207203
};
208204

209205
template <typename T1, typename T2, typename RESULT_TYPE = SEXP>
210-
#if __cplusplus < 201103L
211-
class binary_call : public std::binary_function<T1,T2,RESULT_TYPE> {
212-
#else
213206
class binary_call : public std::function<RESULT_TYPE(T1,T2)> {
214-
#endif
215207
public:
216208
binary_call( Language call_ ) : call(call_), proxy1(call_,1), proxy2(call_,2) {}
217209
binary_call( Language call_, R_xlen_t index1, R_xlen_t index2 ) : call(call_), proxy1(call_,index1), proxy2(call_,index2){}

inst/include/Rcpp/StringTransformer.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
// clone.h: Rcpp R/C++ interface class library -- clone RObject's
33
//
4-
// Copyright (C) 2010 - 2022 Dirk Eddelbuettel and Romain Francois
4+
// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
55
//
66
// This file is part of Rcpp.
77
//
@@ -26,11 +26,7 @@
2626
namespace Rcpp{
2727

2828
template <typename UnaryOperator>
29-
#if __cplusplus < 201103L
30-
class StringTransformer : public std::unary_function<const char*, const char*> {
31-
#else
3229
class StringTransformer : public std::function<const char*(const char*)> {
33-
#endif
3430
public:
3531
StringTransformer( const UnaryOperator& op_ ): op(op_), buffer(){}
3632
~StringTransformer(){}

inst/include/Rcpp/algorithm.h

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// algorithm.h: Rcpp R/C++ interface class library -- data frames
44
//
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
67
//
78
// This file is part of Rcpp.
89
//
@@ -22,14 +23,6 @@
2223
#ifndef Rcpp__Algorithm_h
2324
#define Rcpp__Algorithm_h
2425

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-
3326
namespace Rcpp {
3427
namespace algorithm {
3528

@@ -167,29 +160,29 @@ namespace helpers {
167160
template<>
168161
struct rtype_helper< double > {
169162
typedef double type;
170-
static RCPP_CONSTEXPR_VAR int RTYPE = REALSXP;
163+
static constexpr int RTYPE = REALSXP;
171164
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; }
174167
};
175168

176169
template<>
177170
struct rtype_helper< int > {
178171
typedef int type;
179-
static RCPP_CONSTEXPR_VAR int RTYPE = INTSXP;
172+
static constexpr int RTYPE = INTSXP;
180173
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; }
183176
};
184177

185178
template< typename T >
186179
struct rtype {
187180
typedef typename rtype_helper< typename ctype< T >::type >::type type;
188181
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;
190183
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(); }
193186
};
194187

195188
struct log {
@@ -483,7 +476,4 @@ void sqrt(InputIterator begin, InputIterator end, OutputIterator out) {
483476
} // namespace algorithm
484477
} // namespace Rcpp
485478

486-
#undef RCPP_CONSTEXPR_FUNC
487-
#undef RCPP_CONSTEXPR_VAR
488-
489479
#endif

inst/include/Rcpp/longlong.h

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// longlong.h: Rcpp R/C++ interface class library -- long long support
44
//
55
// Copyright (C) 2013 - 2017 Dirk Eddelbuettel and Romain Francois
6-
// Copyright (C) 2018 Dirk Eddelbuettel, Romain Francois and Kevin Ushey
6+
// Copyright (C) 2018 - 2025 Dirk Eddelbuettel, Romain Francois and Kevin Ushey
77
//
88
// This file is part of Rcpp.
99
//
@@ -23,33 +23,8 @@
2323
#ifndef RCPP_LONG_LONG_H
2424
#define RCPP_LONG_LONG_H
2525

26-
// long long is explicitly available to C++11 (and above) compilers
27-
#if __cplusplus >= 201103L
28-
2926
typedef long long int rcpp_long_long_type;
3027
typedef unsigned long long int rcpp_ulong_long_type;
3128
# define RCPP_HAS_LONG_LONG_TYPES
3229

33-
// GNU compilers may make 'long long' available as an extension
34-
// (note that __GNUC__ also implies clang, MinGW)
35-
#elif defined(__GNUC__)
36-
37-
// check to see if 'long long' is an alias for 'int64_t'
38-
# if defined(_GLIBCXX_HAVE_INT64_T) && defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG)
39-
# include <stdint.h>
40-
typedef int64_t rcpp_long_long_type;
41-
typedef uint64_t rcpp_ulong_long_type;
42-
# define RCPP_HAS_LONG_LONG_TYPES
43-
44-
// check to see if this is an older C++ compiler, but extensions are enabled
45-
# elif defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__clang__) && defined(__LP64__))
46-
# if defined(__LONG_LONG_MAX__)
47-
__extension__ typedef long long int rcpp_long_long_type;
48-
__extension__ typedef unsigned long long int rcpp_ulong_long_type;
49-
# define RCPP_HAS_LONG_LONG_TYPES
50-
# endif
51-
# endif
52-
53-
#endif
54-
5530
#endif

inst/include/Rcpp/utils/tinyformat.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// tinyformat.h: Rcpp R/C++ interface class library -- tinyformat.h wrapper
44
//
55
// Copyright (C) 2008 - 2009 Dirk Eddelbuettel
6-
// Copyright (C) 2009 - 2017 Dirk Eddelbuettel and Romain Francois
6+
// Copyright (C) 2009 - 2025 Dirk Eddelbuettel and Romain Francois
77
//
88
// This file is part of Rcpp.
99
//
@@ -27,14 +27,7 @@ namespace Rcpp {
2727
void stop(const std::string& message);
2828
}
2929
#define TINYFORMAT_ERROR(REASON) ::Rcpp::stop(REASON)
30-
31-
#if __cplusplus >= 201103L
3230
#define TINYFORMAT_USE_VARIADIC_TEMPLATES
33-
#else
34-
// Don't use C++11 features (support older compilers)
35-
#define TINYFORMAT_NO_VARIADIC_TEMPLATES
36-
#endif
37-
3831
#define TINYFORMAT_ASSERT(cond) do if (!(cond)) ::Rcpp::stop("Assertion failed"); while(0)
3932

4033
#include "tinyformat/tinyformat.h"

inst/tinytest/cpp/sugar.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
// sugar.cpp: Rcpp R/C++ interface class library -- sugar unit tests
33
//
4-
// Copyright (C) 2012 - 2022 Dirk Eddelbuettel and Romain Francois
4+
// Copyright (C) 2012 - 2025 Dirk Eddelbuettel and Romain Francois
55
//
66
// This file is part of Rcpp.
77
//
@@ -23,11 +23,7 @@ using namespace Rcpp ;
2323

2424
template <typename T>
2525

26-
#if __cplusplus < 201103L
27-
class square : public std::unary_function<T,T> {
28-
#else
2926
class square : public std::function<T(T)> {
30-
#endif
3127
public:
3228
T operator()( T t) const { return t*t ; }
3329
} ;

src/attributes.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// attributes.cpp: Rcpp R/C++ interface class library -- Rcpp attributes
22
//
33
// Copyright (C) 2012 - 2020 JJ Allaire, Dirk Eddelbuettel and Romain Francois
4-
// Copyright (C) 2021 - 2023 JJ Allaire, Dirk Eddelbuettel, Romain Francois, Iñaki Ucar and Travers Ching
4+
// Copyright (C) 2021 - 2025 JJ Allaire, Dirk Eddelbuettel, Romain Francois, Iñaki Ucar and Travers Ching
55
//
66
// This file is part of Rcpp.
77
//
@@ -401,19 +401,11 @@ namespace attributes {
401401
std::string sig = sigParam.value();
402402
trimWhitespace(&sig);
403403
if (sig.empty()) return sig;
404-
#if __cplusplus < 201103L
405-
if (sig[sig.size() - 1] == '}')
406-
#else
407404
if (sig.back() == '}')
408-
#endif
409405
sig = sig.substr(0, sig.size()-1);
410406
// check sig.empty again since we deleted an element
411407
if (sig.empty()) return sig;
412-
#if __cplusplus < 201103L
413-
if (sig[0] == '{')
414-
#else
415408
if (sig.front() == '{')
416-
#endif
417409
sig.erase(0,1);
418410
return sig;
419411
}

0 commit comments

Comments
 (0)