rendered paste body#include <string>
struct Foo {
void set_str(const std::string& str) {}
void set_str(const char* str) {}
void easy(int str) {}
};
struct Bar {
template <typename ClassType, typename ValueType>
void templateMethod(void (ClassType::*)(ValueType)) {
// Do something with the method pointer.
}
};
int main() {
Bar b;
// Should pass pointer to set_str(const string&), but how to specify that constraint?
b.templateMethod<Foo>(&Foo::easy);
b.templateMethod<Foo,const char *>(&Foo::set_str);
// b.templateMethod<Foo>(&Foo::set_str);
}