fork download
  1.  
  2. struct Object {
  3. int& x() & { return x_; }
  4. private:
  5. int x_;
  6. };
  7.  
  8. int main() {
  9. int x = Object().x();
  10. }
  11.  
  12.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:9:24: error: passing ‘Object’ as ‘this’ argument discards qualifiers [-fpermissive]
     int x = Object().x();
                        ^
prog.cpp:3:10: note:   in call to ‘int& Object::x() &’
     int& x() & { return x_; }
          ^
stdout
Standard output is empty