Skip to content

Commit 8e96c6e

Browse files
committed
three small changes to compile (again) under C++98
1 parent 2154c7e commit 8e96c6e

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2022-01-20 Dirk Eddelbuettel <[email protected]>
2+
3+
* src/attributes.cpp: Make three small changes to permit compilation
4+
under C++98 now (while we consider just turning to C++11 overall)
5+
16
2022-01-14 Dirk Eddelbuettel <[email protected]>
27

38
* inst/tinytest/test_packageversion.R: Comparison to 'dev' revision

src/attributes.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// attributes.cpp: Rcpp R/C++ interface class library -- Rcpp attributes
33
//
44
// Copyright (C) 2012 - 2020 JJ Allaire, Dirk Eddelbuettel and Romain Francois
5-
// Copyright (C) 2021 JJ Allaire, Dirk Eddelbuettel, Romain Francois, Iñaki Ucar and Travers Ching
5+
// Copyright (C) 2021 - 2022 JJ Allaire, Dirk Eddelbuettel, Romain Francois, Iñaki Ucar and Travers Ching
66
//
77
// This file is part of Rcpp.
88
//
@@ -400,12 +400,20 @@ namespace attributes {
400400
Param sigParam = paramNamed(kExportSignature);
401401
std::string sig = sigParam.value();
402402
trimWhitespace(&sig);
403-
if(sig.empty()) return sig;
404-
if(sig.back() == '}')
403+
if (sig.empty()) return sig;
404+
#if __cplusplus < 201103L
405+
if (sig[sig.size() - 1] == '}')
406+
#else
407+
if (sig.back() == '}')
408+
#endif
405409
sig = sig.substr(0, sig.size()-1);
406410
// check sig.empty again since we deleted an element
407-
if(sig.empty()) return sig;
408-
if(sig.front() == '{')
411+
if (sig.empty()) return sig;
412+
#if __cplusplus < 201103L
413+
if (sig[0] == '{')
414+
#else
415+
if (sig.front() == '{')
416+
#endif
409417
sig.erase(0,1);
410418
return sig;
411419
}
@@ -2810,7 +2818,7 @@ namespace attributes {
28102818
// as the error message is generally more descriptive
28112819
CharacterVector pargs_cv = formalArgs(eval(parse(_["text"] = args)));
28122820
std::vector<std::string> parsed_args =
2813-
Rcpp::as<std::vector<std::string>>(pargs_cv);
2821+
Rcpp::as<std::vector<std::string> >(pargs_cv);
28142822

28152823
for(size_t i=0; i<required_args.size(); ++i) {
28162824
if(std::find(parsed_args.begin(), parsed_args.end(),

0 commit comments

Comments
 (0)