fork(2) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct smth
  6. {
  7. template <int i> struct key_t {};
  8.  
  9. int x; int get(key_t<1>) { return this->x; }
  10. double y; double get(key_t<2>) { return this->y; }
  11. };
  12.  
  13. int main()
  14. {
  15. smth s = {1, 2.5};
  16.  
  17. cout << s.x << ' ' << s.y << endl;
  18. cout << s.get(smth::key_t<1>()) << ' ' << s.get(smth::key_t<2>()) << endl;
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
1 2.5
1 2.5