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

Replace result_of by invoke_result for C++17 and above #1999 #2021

Merged
merged 1 commit into from
Mar 13, 2020
Merged

Replace result_of by invoke_result for C++17 and above #1999 #2021

merged 1 commit into from
Mar 13, 2020

Conversation

facug91
Copy link
Contributor

@facug91 facug91 commented Mar 12, 2020

As discussed in #1999, std::result_of is deprecated in C++17 and should be replaced by std::invoke_result. In C++20, std::result_of is removed. What I do in this PR is performing this replacement, when using C++17 or C++20. I used almost the same as in this other PR, from another library fmtlib/fmt#1028.

I also make a minor modification to how std::result_of is use for C++11 and C++14, to comply with how it is recommended (https://en.cppreference.com/w/cpp/types/result_of):

template<class F, class... Args>
std::result_of_t<F&&(Args&&...)> // instead of std::result_of_t<F(Args...)>, which is wrong
  my_invoke(F&& f, Args&&... args) { 
    /* implementation */
}

I ran all tests with gcc7, gcc9 and VS2017 (with C++14, and C++latest).

@davisking
Copy link
Owner

Awesome, thanks for the fix :)

@davisking davisking merged commit 08aeada into davisking:master Mar 13, 2020
nidegen pushed a commit to kapanu/dlib that referenced this pull request Sep 23, 2020
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

Successfully merging this pull request may close these issues.

2 participants