fork(1) download
  1. template <typename T, typename K, K (T::*F)() const = &T::operator K>
  2. struct Foo
  3. {
  4. K retrieve(const T & t) { return (t.*F)(); }
  5. };
  6.  
  7. struct X { operator int() const { return 12; } };
  8.  
  9. #include <iostream>
  10.  
  11. int main()
  12. {
  13. std::cout << Foo<X, int>().retrieve(X()) << "\n";
  14. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
12