fork download
  1. class myclass {
  2. const char* c_str() const && = delete;
  3. };
  4.  
  5. void foo( myclass &&c )
  6. {
  7. c.c_str();
  8. }
  9.  
  10. int main()
  11. {
  12. foo( myclass() );
  13. }
  14.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:7:4: error: attempt to use a deleted function
        c.c_str();
          ^
prog.cpp:2:14: note: 'c_str' has been explicitly marked deleted here
        const char* c_str() const && = delete;
                    ^
prog.cpp:7:4: error: 'c_str' is a private member of 'myclass'
        c.c_str();
          ^
prog.cpp:2:14: note: implicitly declared private here
        const char* c_str() const && = delete;
                    ^
2 errors generated.
stdout
Standard output is empty