From 2e6cc75eb889856e0751af74b9266af834d323d6 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 2 Feb 2023 08:00:43 -0600 Subject: [PATCH 1/2] Permit C++20 compilation via clang and its standard C++ library --- ChangeLog | 5 +++++ inst/include/Rcpp/sugar/functions/sapply.h | 13 +++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 261be152d..238f68bf5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-02-02 Dirk Eddelbuettel + + * inst/include/Rcpp/sugar/functions/sapply.h: Enable compilation + under C++20 (using clang++ and its C++ library) via invoke_result + 2023-01-29 IƱaki Ucar * inst/tinytest/test_xptr.R: Fix a couple of tests writing to stdout diff --git a/inst/include/Rcpp/sugar/functions/sapply.h b/inst/include/Rcpp/sugar/functions/sapply.h index 2ade4063e..8f55d4d34 100644 --- a/inst/include/Rcpp/sugar/functions/sapply.h +++ b/inst/include/Rcpp/sugar/functions/sapply.h @@ -1,8 +1,7 @@ -// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- -// + // sapply.h: Rcpp R/C++ interface class library -- sapply // -// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2023 Dirk Eddelbuettel and Romain Francois // // This file is part of Rcpp. // @@ -33,7 +32,13 @@ template struct sapply_application_result_of { #if defined(RCPP_USING_CXX0X_OR_LATER) - typedef typename ::std::result_of::type type; + #if __cplusplus < 201703L + // deprecated by C++17, removed by C++2020, see https://en.cppreference.com/w/cpp/types/result_of + typedef typename ::std::result_of::type type; + #else + // since C++17, see https://en.cppreference.com/w/cpp/types/result_of + typedef typename ::std::invoke_result::type type; + #endif #else typedef typename ::Rcpp::traits::result_of::type type; #endif From 5e7ca2a1d5cd0f507b00a63e8ee9102a0999381a Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 2 Feb 2023 08:12:45 -0600 Subject: [PATCH 2/2] Small correction --- inst/include/Rcpp/sugar/functions/sapply.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inst/include/Rcpp/sugar/functions/sapply.h b/inst/include/Rcpp/sugar/functions/sapply.h index 8f55d4d34..49ed29a3e 100644 --- a/inst/include/Rcpp/sugar/functions/sapply.h +++ b/inst/include/Rcpp/sugar/functions/sapply.h @@ -37,7 +37,7 @@ struct sapply_application_result_of typedef typename ::std::result_of::type type; #else // since C++17, see https://en.cppreference.com/w/cpp/types/result_of - typedef typename ::std::invoke_result::type type; + typedef typename ::std::invoke_result::type type; #endif #else typedef typename ::Rcpp::traits::result_of::type type;