fork(14) download
  1. #include <iostream>
  2.  
  3. template<class T>
  4. struct larrow {
  5. larrow(T* a_) : a(a_) { }
  6. T* a;
  7. };
  8.  
  9. template <class T, class R>
  10. R operator<(R (T::* f)(), larrow<T> it) {
  11. return (it.a->*f)();
  12. }
  13.  
  14. template<class T>
  15. larrow<T> operator-(T& a) {
  16. return larrow<T>(&a);
  17. }
  18.  
  19. struct C {
  20. void f() { std::cout << "foo\n"; }
  21. };
  22.  
  23. int main() {
  24. C x;
  25. (&C::f)<-x;
  26. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
foo