fr00b0 / nod

Small, header only signals and slots C++11 library.
MIT License
253 stars 49 forks source link

std::result_of is removed in C++20 in favor of std::invoke_result #28

Closed kevin-- closed 2 years ago

kevin-- commented 2 years ago

When building with C++20, result_of does not exist.

So we check the value of __cplusplus to select invoke_result instead

kevin-- commented 2 years ago

@fr00b0 FYI

fr00b0 commented 2 years ago

Hello @kevin-- I'm not sure how what I think about this change. The library was always meant to be a C++ 11 ~14~ library. I have not examined all of the things used to see if deprecation or behavior changes is present with C++ 20.

Edit: C++ 11 ofc, not 14...

kevin-- commented 2 years ago

@fr00b0 as we can see from https://en.cppreference.com/w/cpp/types/result_of the availability notes are

(since C++11)
(deprecated in C++17)
(removed in C++20)

The Notes section explains why result_of had some issues that lead to its eventual removal by the standards committee, and it seems that invoke_result provides identical results with less undefined behavior cases.

my proposed change leaves C++11 compatibility intact but allows me to keep using my favorite signaling library while building against the C++20 standard 🙃

drewr95 commented 2 years ago

@fr00b0 Can we get this accepted? I'd like to see @kevin--'s changes brought in since it leaves C++11 compatibility intact. I would like to keep using this library as well.

fr00b0 commented 2 years ago

Merged to avoid this unfortunate situation with removal after deprecation in newer standards