Question

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> // ???
Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top