// // To forbid copying // // class X { // ... private: X& operator=(const X&); // Disallow copying X(const X&); }; class X : boost::noncopyable { // ... } // // Default and delete functions in Cpp1x // class X { // ... X& operator=(const X&) = delete; // Disallow copying X(const X&) = delete; }; // Conversely, we can also say explicitly that we want to default // copy behavior: class Y { // ... Y& operator=(const Y&) = default; // default copy semantics Y(const Y&) = default; }; Copy on write Specializations