Skip to content

Commit

Permalink
#544 use initializer list to get arg values..
Browse files Browse the repository at this point in the history
- Doesn't crash Clang
- Doesn't require recursive templates
- Not sure why this is not mentioned more online..
  • Loading branch information
pnstickne authored and lifflander committed Nov 27, 2019
1 parent d86c4f7 commit f193a4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 31 deletions.
13 changes: 8 additions & 5 deletions src/vt/registry/auto/auto_registry_general.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ static inline auto proxyOperatorToNewInstanceReg(Args... args) {
/// MULTIPLE INSTANCES of the type will be created and discarded.
/// This cannot be used for a stateful instance.
/// This is an implementation detail that could be reconsidered.
template <typename ObjTypeT, typename... Args>
template <typename ObjTypeT, typename... ArgsT>
struct FunctorAdapterArgs {
using FunctionPtrType = void (*)(Args...);
using FunctionPtrType = void (*)(ArgsT...);
using ObjType = ObjTypeT;

static constexpr FunctionPtrType getFunction() {
return &proxyOperatorToNewInstanceReg<ObjType, Args...>;
return &proxyOperatorToNewInstanceReg<ObjType, ArgsT...>;
}

static std::string traceGetEventType() {
Expand All @@ -97,12 +97,15 @@ struct FunctorAdapterArgs {
static std::string traceGetEventName() {
using TE = vt::util::demangle::TemplateExtract;
using DU = vt::util::demangle::DemanglerUtils;
auto args = DU::join(",", TE::getTypeNames<Args...>());
std::vector<std::string> arg_types = {
TE::getTypeName<ArgsT>()...
};
auto args = DU::join(",", arg_types);
return DU::removeSpaces("operator(" + args + ")");
}

static NumArgsType getNumArgs() {
return sizeof...(Args);
return sizeof...(ArgsT);
}
};

Expand Down
26 changes: 0 additions & 26 deletions src/vt/utils/demangle/demangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,32 +129,6 @@ struct TemplateExtract {
return lastNamedPfType(prettyFunctionForValuePtr<T,value>(), "PF_VALUE_NAME");
}

// 2+ args
template <typename T, typename Tx, typename... Ts>
static void getTypeNamesHelper(std::vector<std::string> & target) {
target.push_back(getTypeName<T>());
getTypeNamesHelper<Tx, Ts...>(target);
}

// 1 args (shouldnt be needed.. avoids Clang 9 compiler crash)
template <typename T>
static void getTypeNamesHelper(std::vector<std::string> & target) {
target.push_back(getTypeName<T>());
}

// 0 args
void getTypeNamesHelper(std::vector<std::string> & target) {
}

/// Return the type names of T..., as a sequence of strings.
/// Requires compiler extension support.
template <typename... T>
static std::vector<std::string> getTypeNames() {
std::vector<std::string> result;
getTypeNamesHelper<T...>(result);
return result;
}

/// Given a string like 'a::b::c', return the namespace of 'a::b'.
/// Removes leading '&', if present (as it appears for 'values representing types').
/// Does not strip out extra template parameterization artifacts.
Expand Down

0 comments on commit f193a4f

Please sign in to comment.