There is a templated member function in some class Foo

template <typename T>
void Foo::bar(std::string &, const T&);

How to make a make pointer to following specialized variant of this function?

void Foo::bar<std::string>(std::string &, const std::string&);

There is like what I mean

typedef void (Foo::*Bar_t)(std::string &, const std::string&);
Bar_t stringedBar = &Foo::bar<std::string> // ???
有帮助吗?

解决方案

Exactly as you have written it.

typedef void (Foo::*Bar_t)(std::string &, const std::string&);
Bar_t stringedBar = &Foo::bar<std::string>;

See here for an example.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top