Advertisement
infamouscheats

sfinktah — conditional result_of/invoke_result

Apr 7th, 2019
1,254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // copied from https://github.com/fmtlib/fmt/pull/1028/commits/e59cf9f7134454d7502a73858f5f9c2aac48b72e
  2. // "Replace 'result_of' by 'std::invoke_result' where possible (#1025) #1028"
  3. template <typename> struct result_of;
  4. #if (__cplusplus >= 201703L ||                          \
  5.      (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) && \
  6.     __cpp_lib_is_invocable >= 201703L
  7. template <typename F, typename... Args>
  8. struct ::result_of<F(Args...)> : std::invoke_result<F, Args...> {};
  9. #else
  10. // A workaround for gcc 4.4 that doesn't allow F to be a reference.
  11. template <typename F, typename... Args>
  12. struct result_of<F(Args...)> : result_of<typename std::remove_reference<F>::type(Args...)> {
  13. };
  14. #endif
  15.  
  16. // copied from <type_traits> in MSVC
  17. #pragma warning(push)
  18. #pragma warning(disable : 4996)  // was declared deprecated
  19. template <class _Ty>
  20. using result_of_t = typename ::result_of<_Ty>::type;
  21. #pragma warning(pop)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement