Skip to content

Commit b1fce6d

Browse files
authored
Merge pull request #1248 from RcppCore/feature/c++20_clang
Enable compilation under C++20 with clang++ and its standard library
2 parents 8d82ab9 + 5e7ca2a commit b1fce6d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2023-02-02 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/include/Rcpp/sugar/functions/sapply.h: Enable compilation
4+
under C++20 (using clang++ and its C++ library) via invoke_result
5+
16
2023-01-29 Iñaki Ucar <[email protected]>
27

38
* inst/tinytest/test_xptr.R: Fix a couple of tests writing to stdout

inst/include/Rcpp/sugar/functions/sapply.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
2-
//
1+
32
// sapply.h: Rcpp R/C++ interface class library -- sapply
43
//
5-
// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
4+
// Copyright (C) 2010 - 2023 Dirk Eddelbuettel and Romain Francois
65
//
76
// This file is part of Rcpp.
87
//
@@ -33,7 +32,13 @@ template <typename Function, typename SugarExpression>
3332
struct sapply_application_result_of
3433
{
3534
#if defined(RCPP_USING_CXX0X_OR_LATER)
36-
typedef typename ::std::result_of<Function(typename SugarExpression::stored_type)>::type type;
35+
#if __cplusplus < 201703L
36+
// deprecated by C++17, removed by C++2020, see https://en.cppreference.com/w/cpp/types/result_of
37+
typedef typename ::std::result_of<Function(typename SugarExpression::stored_type)>::type type;
38+
#else
39+
// since C++17, see https://en.cppreference.com/w/cpp/types/result_of
40+
typedef typename ::std::invoke_result<Function, typename SugarExpression::stored_type>::type type;
41+
#endif
3742
#else
3843
typedef typename ::Rcpp::traits::result_of<Function>::type type;
3944
#endif

0 commit comments

Comments
 (0)