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

C++20 removed std::result_of #1999

Closed
215020267 opened this issue Feb 13, 2020 · 6 comments
Closed

C++20 removed std::result_of #1999

215020267 opened this issue Feb 13, 2020 · 6 comments
Labels

Comments

@215020267
Copy link

Description:
In /std:c++17 mode, this triggers a deprecation warning in recent versions of MSVC. In /std:c++latest mode, now that microsoft/STL#380 has been merged, this will trigger an error in VS 2019 16.6 Preview 2.

Reproduce steps:

  1. git clone https://github.com/davisking/dlib D:\Dlib\src
  2. cd D:\Dlib\src
  3. set CL=/D_HAS_AUTO_PTR_ETC=1 /D_WINSOCKAPI_
  4. mkdir build_amd64
  5. cd D:\Dlib\src\build_amd64
  6. cmake -G "Visual Studio 15 Win64" -DCMAKE_SYSTEM_VERSION=10.0.17134.0 ..
  7. cmake -G "Visual Studio 15 Win64" -DCMAKE_SYSTEM_VERSION=10.0.17134.0 ..\dlib\test
  8. msbuild /m /p:Platform=x64 /p:Configuration=Release Project.sln /t:Rebuild /p:PreferredToolArchitecture=x64

ErrorMessage:
F:\gitP\davisking\dlib\dlib\threads\async.h(55): error C2039: 'result_of': is not a member of 'std' (compiling source file F:\gitP\davisking\dlib\dlib\filtering\kalman_filter.cpp)

@facug91
Copy link
Contributor

facug91 commented Feb 27, 2020

For what I've read, since C++17, std::result_of should replaced by std::invoke_result.
In dlib, it's only being used in the async.h file, and in a way that seems to be wrong (https://en.cppreference.com/w/cpp/types/result_of).
I think we could use a macro to replace std::result_of by std::invoke_result in that part, when the compiler is >= C++17. But the potential problem would still be there for C++11 and C++14.
Maybe someone with better understanding of async.h file, can say if this is safe or not.

@davisking
Copy link
Owner

What's wrong with the current code?

I'm not super excited about using macros to do this, since compilers pretty reliably don't set __cplusplus correctly, especially visual studio. Maybe things are better now, but it wasn't always great. But if toggling on __cplusplus works for MSVC then that's fine, but does it define __cplusplus to be 201703L before it starts warning or even erroring out about std::result_of? All my past experience with visual studio makes me expect it will error on std::result_of long before __cplusplus gets set to 201703L.

@davisking
Copy link
Owner

Anyway, if macros do work then that would be nice, and a PR that toggled on that would be cool :)

@dlib-issue-bot
Copy link
Collaborator

Warning: this issue has been inactive for 35 days and will be automatically closed on 2020-04-15 if there is no further activity.

If you are waiting for a response but haven't received one it's possible your question is somehow inappropriate. E.g. it is off topic, you didn't follow the issue submission instructions, or your question is easily answerable by reading the FAQ, dlib's official compilation instructions, dlib's API documentation, or a Google search.

@dlib-issue-bot
Copy link
Collaborator

Warning: this issue has been inactive for 43 days and will be automatically closed on 2020-04-15 if there is no further activity.

If you are waiting for a response but haven't received one it's possible your question is somehow inappropriate. E.g. it is off topic, you didn't follow the issue submission instructions, or your question is easily answerable by reading the FAQ, dlib's official compilation instructions, dlib's API documentation, or a Google search.

@dlib-issue-bot
Copy link
Collaborator

Notice: this issue has been closed because it has been inactive for 45 days. You may reopen this issue if it has been closed in error.

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

No branches or pull requests

4 participants