Pergunta

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> // ???
Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top