abseil-cpp icon indicating copy to clipboard operation
abseil-cpp copied to clipboard

Remove absl::result_of_t in C++20

Open obsgolem opened this issue 5 years ago • 6 comments

This PR removes absl::result_of_t when compiling for C++20. I did the dead-simplest thing: I just added #if guards everywhere it is used.

Alternatives that spring to mind:

  • Provide a drop in replacement for result_of_t in C++20. I have some commented out code to this effect.
  • Provide an implementation of invoke_result_t in C++14 and earlier, port everything in the library to use this.

Something appears to be wrong with your .clang-format file. It doesn't appear to produce the same results as the formatting that is actually in these files.

obsgolem avatar Jun 06 '20 05:06 obsgolem

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

googlebot avatar Jun 06 '20 05:06 googlebot

@googlebot I signed it!

obsgolem avatar Jun 06 '20 05:06 obsgolem

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

googlebot avatar Jun 06 '20 05:06 googlebot

I think this is worth fixing but I would prefer to use a different approach.

Abseil already has an internal version of invoke_result_t: absl::base_internal::InvokeT. If we use that instead, we can have identical behavior across standard versions.

This change has gotten me to revisit our internal Invoker class. I am working on bringing it up to adapt the new INVOKE() behavior introduced in C++17, and will make absl::base_internal::Invoke and InvokeT be aliases to std::invoke and std::invoke_result_t when those are available.

vslashg avatar Jun 09 '20 21:06 vslashg

Just to touch base with you, I have not lost track of this CL. My initial attempt to correct this involved improving our absl::base_internal::Invoke to provide C++17 INVOKE semantics (unpacking reference_wrappers), but the larger template metaprogramming involved caused our internal compiler memory usage to use too much memory.

My second attempt will be to make Invoke and InvokeT be aliases to std::invoke and std::invoke_result_t in C++17 builds. If this works, and doesn't break our compiles, I can continue down my original planned path.

In any event, I will ultimately replace all uses of result_of with base_internal::InvokeT, whatever form that takes. It shouldn't be too long now.

vslashg avatar Jun 17 '20 16:06 vslashg

Getting a bunch of these errors in MSVC. What's the status of this PR?

Still active, or want me to make suggested changes in a new PR?

@obsgolem @vslashg

SamuelMarks avatar May 01 '21 23:05 SamuelMarks