c++ - C++11 Vector of Pointers to Templated Static Member Function -
say have class goes this:
struct mystruct { template<typename t> static int func() { // template parameter. } }; now want create vector of pointers functions func's prototype. since prototype not depend on template parameter, should possible. and, sure enough, can explicitly typedef pointer func, so:
typedef int (* funcptr)(mystruct * pointer); and then, creating vector easy as:
std::vector<funcptr> funcvector; however, avoid declaring func's prototype twice. possible so?
use decltype:
std::vector<decltype(&mystruct::func<void>)> funcvector;
Comments
Post a Comment