Skip to content
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

Apparent C++20 compilation failure #1244

Closed
eddelbuettel opened this issue Jan 29, 2023 · 11 comments
Closed

Apparent C++20 compilation failure #1244

eddelbuettel opened this issue Jan 29, 2023 · 11 comments

Comments

@eddelbuettel
Copy link
Member

eddelbuettel commented Jan 29, 2023

Per email forwarded by BDR and originally to @stla the 'new at CRAN' package jack bonks:

This fails to install with LLVM clang 15.0.7 (current) with libc++ as its
(native) C++ library.

../Rcpp/include/Rcpp/sugar/functions/sapply.h:36:19: error: no template named
'result_of' in namespace 'std'; did you mean 'traits::result_of'?
        typedef typename ::std::result_of<Function(typename
SugarExpression::stored_type)>::type type;
                         ^~~~~~~~~~~~~~~~
                         traits::result_of
.../Rcpp/include/Rcpp/traits/result_of.h:30:8: note: 'traits::result_of'
declared here
struct result_of{
       ^
 ```
jack 5.0.0 specifies C++20, but std::result_of was removed in that standard
having been deprecated in C++17 according to
https://en.cppreference.com/w/cpp/types/result_of
and replaced by invoke_result since C++17.
@eddelbuettel
Copy link
Member Author

FWIW I have not yet been able to tickle anything on Linux with clang++-15 when working with Rcpp itself and its tests.

@kevinushey
Copy link
Contributor

It looks like std::result_of was removed in C++20, so perhaps that's related?

I think invoke_result is the modern alternative. https://en.cppreference.com/w/cpp/types/result_of

@Enchufa2
Copy link
Member

A simple fix would be to add yet another branch to use invoke_result for C++17 or newer in Rcpp/sugar/functions/sapply.h.

It seems that this was added to support lambda functions in sapply. But the other users of ::Rcpp::traits::result_of (lapply, mapply and outer) still do not support lambdas. So it would be nice to move conditional compilation stuff to Rcpp/traits/result_of.h to generalize this support.

@eddelbuettel
Copy link
Member Author

(Yes, BDR made that comment too. I added it to the web comment, if you replied to email you didn't see it.)

Fully agreed on the need to do this for all *apply functions.

@eddelbuettel
Copy link
Member Author

The package experiencing the issue moved itself from C++20 to C++17.

@stla
Copy link

stla commented Jan 31, 2023

Yes. I used C++20 because it has the contains member function for maps. I replaced it with a classical find for C++17.

@eddelbuettel
Copy link
Member Author

And that of course should not have failed on you. We'll look into it.

Errors apparently only come up with clang++(-15) and its own libc++.

@eddelbuettel
Copy link
Member Author

I took care of the compilation issue, turning lambdas on in the *apply functions is more work ... Anyone?

@Enchufa2
Copy link
Member

Enchufa2 commented Feb 2, 2023

Ok to the quick patch for now. I currently do not have the time to dig deeper.

@eddelbuettel
Copy link
Member Author

Yes we need to unblock this so once PRed and merged I will put a 1.0.10.2 onto the drat repo.

@eddelbuettel
Copy link
Member Author

Closing this as #1248 is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants