RxCpp icon indicating copy to clipboard operation
RxCpp copied to clipboard

C++20 removed std::result_of

Open 215020267 opened this issue 5 years ago • 3 comments

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 --recursive https://github.com/Reactive-Extensions/RxCpp D:\RxCpp\src
  2. cd D:\RxCpp\src
  3. set CL=/D_SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING /D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
  4. mkdir build_amd64
  5. cd D:\RxCpp\src\build_amd64
  6. cmake -G "Visual Studio 15 Win64" -DCMAKE_SYSTEM_VERSION=10.0.17134.0 ..\projects\CMake 2>&1
  7. msbuild /m /p:Platform=x64 /p:Configuration=Debug RxCpp.sln /t:Rebuild /p:BuildInParallel=true 2>&1

ErrorMessage: F:\gitP\Reactive-Extensions\RxCpp\Rx\v2\src\rxcpp\rx-util.hpp(49): error C2039: 'result_of': is not a member of 'std' [F:\gitP\Reactive-Extensions\RxCpp\build_amd64\test\rxcpp_test_defer.vcxproj]

215020267 avatar Feb 14 '20 06:02 215020267

as a starting point, since result_of is available in versions <= 17, and invoke_result is available in versions >= 17, I did this:

// rx-util.hpp
#if _HAS_CXX17
template<class F, class... TN> using invoke_result_t = typename std::invoke_result<F, TN...>::type;
#else
template<class F, class... TN> using invoke_result_t = typename std::result_of<F(TN...)>::type;
#endif

...

template<typename T>
struct is_hashable<T,
    typename rxu::types_checked_from<
        typename filtered_hash<T>::result_type,
        typename filtered_hash<T>::argument_type,
        typename std::invoke_result<filtered_hash<T>, T>::type>::type>
	: std::true_type {};

then I changed all usages from rxu::result_of_t<A(B)> to rxu::invoke_result_t<A, B>

arolson101 avatar Jun 24 '20 15:06 arolson101

Do you know the steps to reproduce it on Mac? I'm looking into this issue but couldn't reproduce it.

tcw165 avatar Dec 05 '21 07:12 tcw165

Can this issue be closed since patch is merged?

amelonpie avatar Oct 17 '23 02:10 amelonpie