문제

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