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

function_ref.h implementation uses a feature that's removed in C++20 #104

Closed
maxgolov opened this issue Jun 11, 2020 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@maxgolov
Copy link
Contributor

maxgolov commented Jun 11, 2020

This code would no longer compile in strict mode with C++20 enabled in Visual Studio 2019 (16.6.2, tools v142):

std::is_convertible<typename std::result_of<F &(Args...)>::type, R>::value,

std::result_of has been permanently removed in C++20. Reference:
https://en.cppreference.com/w/cpp/types/result_of

Implementation needs to be rewritten.

One possible approach is to backport std::result_of into nostd::result_of

The other implementation approach is to rework this code to completely avoid the construct.

Visual Studio 2019 compiler takes very strict stance on removed features. There's also a temporary workaround flag that allows to enable deprecated features ( _HAS_DEPRECATED_RESULT_OF ). But I believe it is incorrect for common SDK API header to rely on a feature that's been permanently removed from C++ standard.

I also tested this to confirm that recent gcc-9 and clang-10 are both OK with that deprecated construct, even if a module is compiled in C++20 mode.. But what Visual C++ is doing (not supporting removed features) - seems like the right thing to do.

@maxgolov maxgolov added the bug Something isn't working label Jun 11, 2020
@maxgolov
Copy link
Contributor Author

Possible fix (pseudocode):

#if (__cplusplus >= 201703L) || (_STL_LANG > 201703L)
          std::is_convertible<typename std::invoke_result<F, Args...>::type, R>::value,
#else
          std::is_convertible<typename std::result_of<F &(Args...)>::type, R>::value,
#endif

I can take a look at it. I hit it when I've been experimenting to measure perf of STL vs nostd, plus verifying ABI compat with different compiler standard flags.

@maxgolov maxgolov changed the title function_ref.h implementation uses a feature that's been REMOVED in C++20 function_ref.h implementation uses a feature that's removed in C++20 Jun 11, 2020
@maxgolov maxgolov self-assigned this Jun 12, 2020
@maxgolov
Copy link
Contributor Author

Fixed by #115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant