diff --git a/src/vt/runnable/invoke.h b/src/vt/runnable/invoke.h index 685b05e8f8..b461b7517d 100644 --- a/src/vt/runnable/invoke.h +++ b/src/vt/runnable/invoke.h @@ -51,6 +51,7 @@ #include #include +#include namespace vt { namespace runnable { @@ -132,29 +133,6 @@ static void EndProcessingInvokeEvent(trace::TraceProcessingTag processing_tag) { } #endif -template < - typename Fn, typename Type, typename T1, - typename std::enable_if_t>::value, int> = 0, - typename... Args -> -decltype(auto) invokeImpl(Type Fn::*f, T1&& obj, Args&&... args) { - return ((*std::forward(obj)).*f)(std::forward(args)...); -} - -template < - typename Fn, typename Type, typename T1, - typename std::enable_if_t>::value, int> = 0, - typename... Args -> -decltype(auto) invokeImpl(Type Fn::*f, T1&& obj, Args&&... args) { - return (std::forward(obj).*f)(std::forward(args)...); -} - -template -decltype(auto) invokeImpl(Callable&& f, Args&&... args) { - return std::forward(f)(std::forward(args)...); -} - template util::Copyable invoke(Args&&... args) { #if vt_check_enabled(trace_enabled) @@ -162,7 +140,7 @@ util::Copyable invoke(Args&&... args) { BeginProcessingInvokeEvent(); #endif - const auto& returnVal = invokeImpl(f, std::forward(args)...); + const auto& returnVal = std::invoke(std::forward(f), std::forward(args)...); #if vt_check_enabled(trace_enabled) EndProcessingInvokeEvent(processing_tag); @@ -178,7 +156,7 @@ util::NotCopyable invoke(Args&&... args) { BeginProcessingInvokeEvent(); #endif - auto&& returnVal = invokeImpl(f, std::forward(args)...); + auto&& returnVal = std::invoke(std::forward(f), std::forward(args)...); #if vt_check_enabled(trace_enabled) EndProcessingInvokeEvent(processing_tag); @@ -194,7 +172,7 @@ util::IsVoidReturn invoke(Args&&... args) { BeginProcessingInvokeEvent(); #endif - invokeImpl(f, std::forward(args)...); + std::invoke(std::forward(f), std::forward(args)...); #if vt_check_enabled(trace_enabled) EndProcessingInvokeEvent(processing_tag);