Skip to content

Three small changes to compile (again) under C++98 (closes #1192) #1193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2022-01-20 Dirk Eddelbuettel <edd@debian.org>

* src/attributes.cpp: Make three small changes to permit compilation
under C++98 now (while we consider just turning to C++11 overall)

2022-01-14 Dirk Eddelbuettel <edd@debian.org>

* inst/tinytest/test_packageversion.R: Comparison to 'dev' revision
Expand Down
20 changes: 14 additions & 6 deletions src/attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// attributes.cpp: Rcpp R/C++ interface class library -- Rcpp attributes
//
// Copyright (C) 2012 - 2020 JJ Allaire, Dirk Eddelbuettel and Romain Francois
// Copyright (C) 2021 JJ Allaire, Dirk Eddelbuettel, Romain Francois, Iñaki Ucar and Travers Ching
// Copyright (C) 2021 - 2022 JJ Allaire, Dirk Eddelbuettel, Romain Francois, Iñaki Ucar and Travers Ching
//
// This file is part of Rcpp.
//
Expand Down Expand Up @@ -400,12 +400,20 @@ namespace attributes {
Param sigParam = paramNamed(kExportSignature);
std::string sig = sigParam.value();
trimWhitespace(&sig);
if(sig.empty()) return sig;
if(sig.back() == '}')
if (sig.empty()) return sig;
#if __cplusplus < 201103L
if (sig[sig.size() - 1] == '}')
#else
if (sig.back() == '}')
#endif
sig = sig.substr(0, sig.size()-1);
// check sig.empty again since we deleted an element
if(sig.empty()) return sig;
if(sig.front() == '{')
if (sig.empty()) return sig;
#if __cplusplus < 201103L
if (sig[0] == '{')
#else
if (sig.front() == '{')
#endif
sig.erase(0,1);
return sig;
}
Expand Down Expand Up @@ -2810,7 +2818,7 @@ namespace attributes {
// as the error message is generally more descriptive
CharacterVector pargs_cv = formalArgs(eval(parse(_["text"] = args)));
std::vector<std::string> parsed_args =
Rcpp::as<std::vector<std::string>>(pargs_cv);
Rcpp::as<std::vector<std::string> >(pargs_cv);

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