fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. class Foo {
  5. public:
  6. template <typename T>
  7. void bar(std::string & str, const T& x) {
  8. std::cout << str << ' ' << x << std::endl;
  9. }
  10. };
  11.  
  12. int main() {
  13. typedef void (Foo::*Bar_t)(std::string &, const std::string&);
  14. Bar_t stringedBar = &Foo::bar<std::string>;
  15.  
  16.  
  17. std::string str = "Hello";
  18.  
  19. Foo f;
  20. (f.*stringedBar)(str, "Baz");
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
Hello Baz