vendredi 23 septembre 2016

std::map of string <-> function pairs where function has template argument

I'm trying to create a map of string to function pointers, but with a twist-- the functions have a template argument. Here's what I tried:

template <typename T>
using func = void (*) (T);

std::map<std::string, func> funcMap;
funcMap["test1"] = &Test::test1;
funcMap["test2"] = &Test::test2; 

Test would look something like:

class Test
{
void test1(SomeClass arg) {}
void test2(SomeOtherClass arg) {}
};

Is what I'm attempting possible? Is there a better way to go about it? Thanks!

Aucun commentaire:

Enregistrer un commentaire