#include <memory> class T {public: T() = default; // Disallow moving: T(T&&) = delete; T& operator = (T&&) = delete;}; int main() { // Moving a unique_ptr works: std::unique_ptr<T> a(new T); std::unique_ptr<T> b(std::move(a)); // Moving a T does not work: T x; T y(std::move(x)); //< Compile error}
Standard input is empty
prog.cpp: In function ‘int main()’: prog.cpp:19:18: error: use of deleted function ‘T::T(T&&)’ T y(std::move(x)); //< Compile error ^ prog.cpp:8:2: error: declared here T(T&&) = delete; ^
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!