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> // ???
Was it helpful?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top