Fix usage of result_of under C++20

This commit is contained in:
Charles Milette 2020-03-29 19:47:18 -04:00
parent 67cc66080d
commit 4d87e19b01
No known key found for this signature in database
GPG Key ID: 1A5AE81377AD973A
2 changed files with 11 additions and 1 deletions

View File

@ -970,7 +970,7 @@ struct InvokeMethodWithoutArgsAction {
Class* const obj_ptr;
const MethodPtr method_ptr;
using ReturnType = typename std::result_of<MethodPtr(Class*)>::type;
using ReturnType = typename InvokeResult<MethodPtr, Class*>::type;
template <typename... Args>
ReturnType operator()(const Args&...) const {

View File

@ -460,6 +460,16 @@ struct Function<R(Args...)> {
template <typename R, typename... Args>
constexpr size_t Function<R(Args...)>::ArgumentCount;
// C++11 and 14 compatible invoke_result
template<typename C, typename... Args>
struct InvokeResult {
#ifdef __cpp_lib_is_invocable
typedef typename std::invoke_result<C, Args...>::type type;
#else
typedef typename std::result_of<C(Args...)>::type type;
#endif
};
#ifdef _MSC_VER
# pragma warning(pop)
#endif