fork(1) download
class noncopyable {
public:
    noncopyable(noncopyable &&) noexcept;

    noncopyable &operator=(noncopyable &&) noexcept;

protected:
    noncopyable() = default;

    ~noncopyable() = default;

    noncopyable(const noncopyable &) = delete;

    noncopyable &operator=(const noncopyable &) = delete;
};

class C: noncopyable {
public:
	// compiles if this line is uncommented
	// C(C&& c);

	C() {}
	
	// also compiles if this is commented
	~C() {}
};

C a() {
	return {};
}

C b() {
	return a();
}

int main() {
	return 0;
}
Compilation error #stdin compilation error #stdout 0s 3408KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'C b()':
prog.cpp:31:11: error: use of deleted function 'C::C(const C&)'
  return a();
           ^
prog.cpp:17:7: note: 'C::C(const C&)' is implicitly deleted because the default definition would be ill-formed:
 class C: noncopyable {
       ^
prog.cpp:17:7: error: use of deleted function 'noncopyable::noncopyable(const noncopyable&)'
prog.cpp:12:5: note: declared here
     noncopyable(const noncopyable &) = delete;
     ^
stdout
Standard output is empty