Skip to content

Commit

Permalink
#2140: Invoke: Make CallableWrapper c++17 friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Jun 6, 2023
1 parent aa645bd commit 026332b
Showing 1 changed file with 11 additions and 31 deletions.
42 changes: 11 additions & 31 deletions src/vt/runnable/invoke.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "vt/trace/trace_registry.h"

#include <type_traits>
#include <functional>

namespace vt { namespace runnable {

Expand Down Expand Up @@ -90,46 +91,25 @@ static std::string CreateEventName() {
return DU::removeSpaces(barename + "(" + argsV + ")");
}

template <typename FunctionType, FunctionType f>
struct CallableWrapper;

template <typename Ret, typename... Args, Ret (*f)(Args...)>
struct CallableWrapper<Ret(*)(Args...), f> {
using Type = Ret(*)(Args...);

static std::string GetEventTypeName() {
return CreateEventTypeCStyleFunc<Type, f>();
}

static std::string GetEventName() {
return CreateEventName<Type, f, Args...>();
}

static trace::TraceEntryIDType GetTraceID() {
return trace::TraceRegistry::registerEventHashed(
GetEventTypeName(), GetEventName()
);
}
};

template <
typename Ret, typename Class, typename... Args, Ret (Class::*f)(Args...)
>
struct CallableWrapper<Ret (Class::*)(Args...), f> {
using Type = Ret (Class::*)(Args...);
template <auto f>
struct CallableWrapper {
using Type = decltype(f);

static std::string GetEventTypeName() {
return CreateEventTypeMemberFunc<Class>();
if constexpr (std::is_member_function_pointer_v<Type>) {
return CreateEventTypeMemberFunc<util::FunctionWrapper<Type>>();
} else {
return CreateEventTypeCStyleFunc<Type, f>();
}
}

static std::string GetEventName() {
return CreateEventName<Type, f, Args...>();
return CreateEventName<Type, f>();
}

static trace::TraceEntryIDType GetTraceID() {
return trace::TraceRegistry::registerEventHashed(
GetEventTypeName(), GetEventName()
);
GetEventTypeName(), GetEventName());
}
};

Expand Down

0 comments on commit 026332b

Please sign in to comment.