@@ -91,18 +91,16 @@ namespace mbed {
9191 * in the base declaration.
9292 *
9393 * To solve that problem, the copy constructor and assignment operator have to
94- * be declared (but don't need to be defined) in the private section of the
95- * Connection class:
94+ * be defined as deleted:
9695 *
9796 * @code
9897 * struct Connection {
99- * private:
100- * Connection(const Connection&);
101- * Connection& operator=(const Connection&);
98+ * Connection(const Connection &) = delete;
99+ * Connection &operator=(const Connection &) = delete;
102100 * }
103101 * @endcode
104102 *
105- * Although manually declaring private copy constructor and assignment functions
103+ * Although manually defining deleted copy constructor and assignment functions
106104 * works, it is not ideal. These declarations are usually easy to forget,
107105 * not immediately visible, and may be obscure to uninformed programmers.
108106 *
@@ -211,18 +209,18 @@ class NonCopyable {
211209 }
212210
213211#else
214- private :
212+ public :
215213 /* *
216- * Declare copy constructor as private . Any attempt to copy construct
214+ * Define copy constructor as deleted . Any attempt to copy construct
217215 * a NonCopyable will fail at compile time.
218216 */
219- NonCopyable (const NonCopyable &);
217+ NonCopyable (const NonCopyable &) = delete ;
220218
221219 /* *
222- * Declare copy assignment operator as private . Any attempt to copy assign
220+ * Define copy assignment operator as deleted . Any attempt to copy assign
223221 * a NonCopyable will fail at compile time.
224222 */
225- NonCopyable &operator =(const NonCopyable &);
223+ NonCopyable &operator =(const NonCopyable &) = delete ;
226224#endif
227225#endif
228226};
0 commit comments