fork(5) download
  1. #include <utility>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. template< class T >
  6. T &
  7. operator->*( pair<T,T> &l, bool r )
  8. { return r? l.second : l.first; }
  9.  
  10. template< class T >
  11. T & operator->*( bool l, pair<T,T> &r ) { return r->*l; }
  12.  
  13. int main() {
  14. pair<int, int> y( 5, 6 );
  15. y->*(0) = 7;
  16. y->*0->*y = 8; // evaluates to 7->*y = y.second
  17. cerr << y.first << " " << y.second << endl;
  18. }
Success #stdin #stdout 0s 2892KB
stdin
Standard input is empty
stdout

Standard output is empty